PDA

View Full Version : print_r() not printing array


AN-net
06-30-2005, 03:02 AM
for some reason when i use print_r() on this array it only prints array().
can someone explain to me why?

here is the code

if($_REQUEST['do']=="index")
{
$vbjclass= new vbjournal();

$cache= $vbjclass->cache_journals();
print_r ($cache);
$journals= $vbjclass->grabjournals($cache);
}

Link14716
06-30-2005, 07:54 AM
for some reason when i use print_r() on this array it only prints array().
can someone explain to me why?

here is the code

if($_REQUEST['do']=="index")
{
$vbjclass= new vbjournal();

$cache= $vbjclass->cache_journals();
print_r ($cache);
$journals= $vbjclass->grabjournals($cache);
}

It'd only print array() if the array is empty.

The Geek
06-30-2005, 08:40 AM
It'd only print array() if the array is empty.
Just as an FYI, heres the function I always use when I mack for dumping vars. pretty handy if you ask me :)


function debug_array($array,$echo_on_empty=1;$title='Values '){
if (is_array($array)){
echo("<br /> Array: $title<hr><pre>");
print_r(array_values($array));
echo("</pre><br />End Array $title<hr>");
}elseif($echo_on_empty){
echo("<br />Array $title is empty!<br />");

}
}

AN-net
06-30-2005, 12:48 PM
ok ty:)