Jump to content

find and replace text


fer0an

Recommended Posts

<?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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.