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 Quote Link to comment 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 Quote Link to comment 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); Quote Link to comment 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.