fer0an Posted November 6, 2010 Share Posted November 6, 2010 hello I've some code and I want remove text between Publisher: and >. This text is not fixed. anyone can help me to find text between two char and replace them with "" using php? thank you Link to comment https://forums.phpfreaks.com/topic/217912-find-and-replace-text/ Share on other sites More sharing options...
inversesoft123 Posted November 6, 2010 Share Posted November 6, 2010 <?php $string = "The Publisher: Abhijeet here > hello how are you."; $pices = explode("Publisher:", $string); echo $pices[0]; // prints : The Publisher echo $pices[1]; // prints : Abhijeet here > hello how are you. $pices1 = explode(">", $pices[1]); echo $pices1[0]; // prints : Abhijeet here $newstring = "Publisher:John here>"; $combine = "$pices[0].$newstring.$pices1[1]"; echo $combine; // The Publisher: John here > hello how are you. Then you can replace text Link to comment https://forums.phpfreaks.com/topic/217912-find-and-replace-text/#findComment-1130959 Share on other sites More sharing options...
inversesoft123 Posted November 6, 2010 Share Posted November 6, 2010 function greatexplode($characters,$string) { $takeary = explode($characters[0],$string); array_shift($characters); if($characters != NULL) { foreach($takeary as $key => $val) { $takeary[$key] = multiexplode($characters, $val); } } return $takeary; } $string = "The Publisher: Abhijeet here > hello how are you."; $characters = Array("Publisher:">"); $results = greatexplode($characters,$string); print_r($results); Link to comment https://forums.phpfreaks.com/topic/217912-find-and-replace-text/#findComment-1130962 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.