php console from array code example
Example 1: php echo an array to console
echo "<script>console.log('" . json_encode($data) . "');</script>";
Example 2: php array to console
function console_log( $data ){
echo '<script>';
echo 'console.log('. json_encode( $data ) .')';
echo '</script>';
}
Usage:
$myvar = array(1,2,3);
console_log( $myvar ); // [1,2,3]