1

Here I have a single dimension numeric array

$x = array(1,2,3,4);

Below converted to an object array

$x = (object) $x;

I am not able to access values by its index

echo  $x->{'1'} //Tried but not working
Dharmendra Singh
  • 1,186
  • 12
  • 22

1 Answers1

0

Remove the quotes from the index in the echo statement:

$x = array(1,2,3,4);
$x = (object) $x;

echo $x->{1};

Returns

2

Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119