My output is like this:
Array (
[0] => Array (
[type] => 1
[position] => main-widgets
[key_position] => 3
[code] => template/portfolio.inc
)
[1] => Array (
[type] => 2
[position] => main-widgets
[key_position] => 3
[code] => This is a code
)
) `
How can I check if in_array(Array[position]=='main-header' Without using foreach?
This is my code:
if(in_array('main-header', array_column($PAGE['templates'], 'position'))) {
$count = array_count_values($PAGE['templates']['position']);
if($count['main-header']>1){
echo 'multiple';
foreach($PAGE['templates'] as $pos){
if($pos['type'] == 1){
require $base['basepath'].$pos['code'];
}else {
echo $pos['code'];
}
}
} else {
echo 'Only 1';
if($PAGE['templates']['type'] == 1){
require $base['basepath'].$PAGE['templates']['code'];
}else {
echo $PAGE['templates']['code'];
}
}
}