/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /** * Note This has been tested on PHP5 * I haven't tried it on PHP4 */ "name" => "Jamie Allison", "age" => "31" ); // This is all that is required to cast an array to an object. $data = (object)$arr; // Next create an object manually, with the same data. // For comparison purposes below. $test = new StdClass; $test->name = "Jamie Allison"; $test->age = "31"; // Print out the Results, first dump the manually created class // Print out the Array Cast as an object. ?>