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

 

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);

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.