I'm sure this must have been covered a thousand times, but can't find anything anywhere about this.
I want to get $tags, which is an array with a set of existing values to get the new values from this loop :
$search = ";";
$replace = "";
if (count($tags) > 0) {
foreach ($tags as $tag) {
echo "LOOP 1:"; echo $tag;
$cleantag = str_replace($search, $replace, $tag);
$tag = $cleantag;
echo "LOOP 2:"; echo $tag;
$tags[$tag->name] = $cleantag;
echo "LOOP 3:"; echo $tags[$tag->name];
}
}
echo "<p>TAGS :</p>"; print_r($tags);
The loop works great in that it successfully removes the semicolons, which is verified by echo'ing the values of the individual variables in the loop. Everything seems to go right.
But when printing the value of the $tags array after this loop all semicolons are still there.
How can I get $tags to contain the new values from the loop?
I can't get it into my head, how it would not work. I'm a PHP newbie, but I'm a quick learner.
This is used in a WordPress plugin btw, but strikes me as more of a PHP issue, why I post it here, where there's a bigger chance to get help :-)
Thanks for your help in advance!