4

Can anybody explain?

<?php 
$var = new stdClass();
$var->{1} = 1;
$var->{2} = 2;

$test = (array) $var;

var_dump($test);
var_dump(array_key_exists("2", $test));

It returns false. Is it expected result? OSX 10.10. PHP:5.5.14 Thanks!

1
  • Alternative answer to the ones provided in the question this is duplicating is $test = json_decode(json_encode($var), true); Commented Apr 14, 2015 at 10:59

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.