I am trying to create a server side find and replace script. I borrowed some of the code from another script, but the main part of the script was encoded.
I am a newbie to PHP but have been reading at php.net and MelonFire.com's free tutorials.
here is what I have in my script:
<?php
// Sets location to search
$location = $_POST['location'];
// The string to replace
$find = $_POST['find'];
// The string that replaces $find
$replace = $_POST['replace'];
// Runs through text to replace $find
$output = str_replace($find , $replace , $location);
// Display the output of what happened
echo $output;
?>
Whenever I run it from the form page, all it outputs is the $location.
I know i'm doing something wrong and I don't know is str_replace() is the best function for this. Let me know if preg_replace() or ereg_replace() would be better, I don't know the difference.
Thanks,
Brandon