Reputation: 1977
I need a PHP function that accepts a string, searches for a certain sub string and then replaces that sub string with something else.
Example:
If anyone has any suggestions I'd really appreciate it
Oh yeh, the string is within an element of an array example array[this_string],I need to change the contents of the string within the element of the array.
Thanks!
Upvotes: 1
Views: 304
Reputation: 3798
Read about the str_replace function
http://php.net/manual/en/function.str-replace.php
$raw = 'www.google.com/%hello% Search for: %hello%';
$str = str_replace("%hello%", "hi", $raw);
echo $str;
Upvotes: 3