Nehm4
02-22-2010, 08:29 PM
Hey all,
In php I have an included file via "include_once". In that file there is another included file in the same way. In that included file I have a function that creates an array from another function. When I print_r the array, it's correct, and is_array returns true. However, when I run the array_keys function, it outputs an error saying that it's not an array. Anyone else have this issue?
Thanks!
-josh
PS:
The code
<?php
function arr_val_filt_2_var_pound_ret($v){
return '###' . $v . '###';
}
function var2child_replace_return($path, $text){
$return = '';
if(isset($text)){
$return = $text;
if(isset($path)){
$var_sig = '###';
$child = child_return($path);
$name = array_keys($child);
$name = array_filter($name, "arr_val_filt_2_var_pound_ret");
$text = str_replace($name, $child, $text);
$return = $text;
}
}
return $return;
}
function child_return($path){
global $cfh;
$return = array();
if(isset($path)){
$exceptions = array(
'.',
'..',
'asset',
'asset_share',
'edit'
);
$child = $cfh->contents($path);
foreach($child as $key => $value){
if($value['type'] == 'dir'){
if(!in_array($value['name'], $exceptions)){
$return[$value['name']] = include_once($value['dir'] . '/index.php');
}
}
}
}
return $return;
}
?>
In php I have an included file via "include_once". In that file there is another included file in the same way. In that included file I have a function that creates an array from another function. When I print_r the array, it's correct, and is_array returns true. However, when I run the array_keys function, it outputs an error saying that it's not an array. Anyone else have this issue?
Thanks!
-josh
PS:
The code
<?php
function arr_val_filt_2_var_pound_ret($v){
return '###' . $v . '###';
}
function var2child_replace_return($path, $text){
$return = '';
if(isset($text)){
$return = $text;
if(isset($path)){
$var_sig = '###';
$child = child_return($path);
$name = array_keys($child);
$name = array_filter($name, "arr_val_filt_2_var_pound_ret");
$text = str_replace($name, $child, $text);
$return = $text;
}
}
return $return;
}
function child_return($path){
global $cfh;
$return = array();
if(isset($path)){
$exceptions = array(
'.',
'..',
'asset',
'asset_share',
'edit'
);
$child = $cfh->contents($path);
foreach($child as $key => $value){
if($value['type'] == 'dir'){
if(!in_array($value['name'], $exceptions)){
$return[$value['name']] = include_once($value['dir'] . '/index.php');
}
}
}
}
return $return;
}
?>