Look, you shouldn't take anybody for a fool. This is not the place to get your homework done. I already suggested you to read the "String functions" chapter. Maybe a few ideas about PCRE would be useful as well.
And I tell you again, look into string functions, especially at substr_replace, strtok, strstr and strpos. Pick what suits you best and start coding on your own.
I don't want to sound harsh, but don't look at the number of my posts, I'm not a "junior" for a long time now, I just recently registered with this forum.