Skip to content

Instantly share code, notes, and snippets.

@TLMcode
Created February 19, 2018 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TLMcode/c23d5a2c0b0916ba12655710b547a639 to your computer and use it in GitHub Desktop.
Save TLMcode/c23d5a2c0b0916ba12655710b547a639 to your computer and use it in GitHub Desktop.
Pushing values into PHP Object Arrays
$ObjectArr = (Object) [ "name" => (Object) [ "subarr" => [] ] ];
array_push( $ObjectArr->name->subarr, "value", "poo", "next" );
echo $ObjectArr->name->subarr[ 0 ];
/*
$ObjectArr
stdClass (1) ( public 'name' -> stdClass (1) ( public 'subarr' -> array (3) [ 0 => string (3) "foo" 1 => string (3) "bar" 2 => string (4) "next" ] ) )
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment