Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php array to object

// Typecasting
$person = (object) [ 
  "name"        => "Mr. Jhonson", 
  "description" => "Lorem ipsum dolor sit amet consectetur adipisicing elit", 
  "addresses"   => [ "line1" => "Lorem ipsum dolor", ], ]; 

$person->name; // "Mr. Jhonson"
$person->addresses['line1']; // "Lorem ipsum dolor"
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #array #object
ADD COMMENT
Topic
Name
7+3 =