Print or Display PHP array in Browser Console or in Javascript


Last Update : 2023-09-22 UTC 08:49:45 AM

Answers of > Print or Display PHP array in Browser Console or in Javascript

w3coded console array w3coded console array @Kavin. Glad to hear it but this solution w3coded console array is different. Here you can use the json object w3coded console array from javascript. In the accepted solution, the w3coded console array json object is passed to javascript as a w3coded console array string. w3coded console array – JazZ Feb w3coded console array 19 '17 at 8:15 , w3coded console array w3coded console array Stack Overflow for Teams w3coded console array Where developers & technologists share w3coded console array private knowledge with coworkers w3coded console array , w3coded console array What kind of substance that w3coded console array existed in the middles ages could, when ignited, w3coded console array potentially destroy everything within several w3coded console array miles? ,Note: I w3coded console array understand this question is asking about arrays, w3coded console array so string is probably fine, but to represent w3coded console array more complex objects this works better.


echo "<script>console.log('" . json_encode($data) . "');</script>";

Try adding JSON.parse in addition to what the others said - that way it gets console.logged as an object, meaning you can expand it and navigate it in Chrome like so.

 echo "<script>console.log(JSON.parse('" . json_encode($data) . "'));</script>";

I'm using

echo "<script>console.log(".json_encode(var_export($object, true)).");</script>";

PHP file :


$data = array(
    "data" => "Hello",
    "data1" => "World"

echo "<script>console.log(".json_encode($data).");</script>";

Current topics : Print or Display PHP array in Browser Console or in Javascript

Newly Added Questions

Similar Questions

Questions :

How To Group Array Key Value

Last Update : 2023-09-22 UTC 13:27:15 PM

Questions :

PhpStorm Warning For React Attributes In Jsx File With SCSS File

Last Update : 2023-09-22 UTC 13:26:59 PM

Questions :

Why Is The File Not Showing Up In Request.files And In Request.forms Instead?

Last Update : 2023-09-22 UTC 13:26:54 PM

Questions :

Proxying Assets From React App Directory In Slim Framework?

Last Update : 2023-09-22 UTC 13:26:42 PM

Questions :

Laravel 5.4 Can't Run “php Artisan Preset React” Comand

Last Update : 2023-09-22 UTC 13:26:25 PM

Questions :

How To Update Session Values Without Signing Out?

Last Update : 2023-09-22 UTC 13:26:08 PM

Questions :

Array Is Not Visible

Last Update : 2023-09-22 UTC 13:25:52 PM

Questions :

React Routing For Login Using Symfony

Last Update : 2023-09-22 UTC 13:25:42 PM

Questions :

Sanctum With React SPA Returning 419 Page Expired

Last Update : 2023-09-22 UTC 13:25:36 PM

Questions :

How Do I Import An Input String Into Another Page

Last Update : 2023-09-22 UTC 13:25:30 PM

© 2023 W3CODED - All Rights Reserved.