ccampbell / chromephp

class for logging PHP variables to Google Chrome console
http://www.chromelogger.com
1.38k stars 450 forks source link

Example for ChromePhp::table() #59

Closed Svish closed 7 years ago

Svish commented 7 years ago

Could you add an example of how to use the table type? Not really understanding how to use it properly... like... what do I pass in there? 🤔

Tried looking in the techspecs and in ChromePhp.php, but yeah... not feeling any wiser 😕

marqusG commented 7 years ago

I have just got a solution. You have to pass an array of array: each child array is a row in the table and each value in the child array is a column. A column with index is automatically added in the log. So the following call: include 'ChromePhp.php'; $p1 = array( array('John', 'Wayne', 'M'), array('Gena', 'Rowllands', 'F'), array('Clark', 'Gable', 'M') ); ChromePhp::table($p1); gives you the following result screenshot - 07_19_17 20_06_03

Svish commented 7 years ago

Thanks, that made sense, and worked. 🎉 Seems it also works to use assoc arrays for providing column and/or row titles. 👍