Created
August 19, 2013 10:02
-
-
Save ahmedghazi/6267608 to your computer and use it in GitHub Desktop.
PHP stdClass: Storing Data in an Object Instead of an Array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$book = new stdClass; | |
$book->title = "Harry Potter and the Prisoner of Azkaban"; | |
$book->author = "J. K. Rowling"; | |
$book->publisher = "Arthur A. Levine Books"; | |
$book->amazon_link = "http://www.amazon.com/dp/0439136369/"; | |
$array = array( | |
"title" => "Harry Potter and the Prisoner of Azkaban", | |
"author" => "J. K. Rowling", | |
"publisher" => "Arthur A. Levine Books", | |
"amazon_link" => "http://www.amazon.com/dp/0439136369/" | |
); | |
$books = (object) $array; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment