Jump to content

Need help using foreach


djones

Recommended Posts

I can't seem to get my mind on this correctly. I need $page_content to go through each function, but It seems to either replace itself or duplicate itself.

 

$filter is an array of function names

$count = count($filter);

if($count > 0){

foreach($filter as &$func){

	$page_content = $func($content); // where the function returns the content. see sample functions below
                // $page_content .= $func($content); // not working either

}

}

function replace_text($content){

$content = str_ireplace('test', 'WORKING', $content);

return $content;

}

function replace_text_again($content){

$content = str_ireplace('page', 'THIS AN EXAMPLE', $content);

return $content;

}


echo $page_content;

Link to comment
https://forums.phpfreaks.com/topic/190328-need-help-using-foreach/
Share on other sites

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.