I have an array called $blocks that print_r() function on it will result:
Array ( [0] => template.header [1] => error [2] => emails.addEmail )
and here is my code is:
if(count($blocks)) {
foreach ($blocks as $block) {
echo $block;
$parts = explode('.', $block);
if (count($parts) > 1) {
list($folder, $file) = $parts;
$folder = $folder . '/';
echo BASE . '/blocks/' . $folder . $file . '.php';
} else {
echo BASE . '/blocks/' . $file . '.php';
}
}
$parts = null;
}
but it's acting strangely and echo on line 3 gives me this:
template.header
error
error
The third one must be emails.addEmail but it's duplicating the second one.
Can anyone tell me what is wrong with my code?
Update: I removed @ and replaced it with if (count($parts) > 1). Sorry about that guys. But it doesn't have anything to do with my problem! Still need help...
Update 2: I was using $block variable somewhere before this code and it was connected by reference to another thing. The problem got fixed by changing that variable name. Thanks you guys for your help.
includestatements?/var/www/newsletter/blocks/template/header.php3 times!