mjahkoh Posted August 19, 2011 Share Posted August 19, 2011 I got an Array whereby the contents are to be searched in a string and removed(stripped) . This leaves the text bare of the 'Subtitle'. The text is derived in a loop so only one field will be available in a loop eg 'Address: P.O. Box 4, Mogososiek 20403'. So we search and remove 'Address:' $subtitle = array('Category :','Location:','Address:','Telephone:','City:','Region:','Description :','Website:','Email:','Postcode:','Street:','Phone:','County:'); $text = "Category : Western Province, Location: Address: P.O. Box 4, Mogososiek 20403 Telephone: 052-21051 City: Mogososiek Region: Western Description : "; Please help Regards, Jackson Quote Link to comment https://forums.phpfreaks.com/topic/245191-search-elements-of-an-array-in-text/ Share on other sites More sharing options...
AyKay47 Posted August 19, 2011 Share Posted August 19, 2011 foreach($subtitle as $value){ if(strpos($text,$value)){ str_replace($value,'',$text); } } Quote Link to comment https://forums.phpfreaks.com/topic/245191-search-elements-of-an-array-in-text/#findComment-1259381 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.