- Impact
- 16
Prevent Arrays From Executing Value....
Hey,
Okay i am writing a bulk replacer that searches a document for a certain tag and then replaces it with the appropriate value/function value.
But.. is there a way to get it not to execute every damn function listed in the array... god its hard to explain, ill let the code do the talking:
Unfortunately it seems to.. when looping through the arrays execute any functions it finds each time, meaning i end up with obsurd numbers of database queries for simple pages when some tags are not in use.. in this example get_side_left() will be executed even though there is no tag for it...
Any ideas how to get it to to only execute tags found in the script? (Note that functions like get_header() will get the header file and bring some extra tags into the equation :P So thats why i've had to do it using this method in order...
How do i get it to stop executing functions that aren't needed! :loveyou:
Hey,
Okay i am writing a bulk replacer that searches a document for a certain tag and then replaces it with the appropriate value/function value.
But.. is there a way to get it not to execute every damn function listed in the array... god its hard to explain, ill let the code do the talking:
PHP:
$page='
<-(GET_HEADER)->
Thats the header.. then i think ill have a footer
<-(GET_FOOTER)->';
$MasterArray=array('<-(GET_HEADER)->','<-(GET_FOOTER)->','<-(GET_SIDEBAR_LEFT)->');
$MasterFinalArray=array(get_header(),get_footer(),get_side_left());
$replace=str_replace($MasterArray,$MasterFinalArray,$page);
Unfortunately it seems to.. when looping through the arrays execute any functions it finds each time, meaning i end up with obsurd numbers of database queries for simple pages when some tags are not in use.. in this example get_side_left() will be executed even though there is no tag for it...
Any ideas how to get it to to only execute tags found in the script? (Note that functions like get_header() will get the header file and bring some extra tags into the equation :P So thats why i've had to do it using this method in order...
How do i get it to stop executing functions that aren't needed! :loveyou:







