1

Possible Duplicate:
Diddling with arrays with numeric string keys

As specified in PHP's manual, we can do type casting on objects and covert them to array as follows:

$arrayResult = (array)$someObject;

But I found very interesting remark in documentation:

If an object is converted to an array, the result is an array whose elements are the object's properties. The keys are the member variable names, with a few notable exceptions: integer properties are innaccessible

What does "integer properties" stands for?

2

2 Answers 2

0

I believe this means that you cannot use typical integer properties of arrays to iterate through, such as in a for loop. The elements are not integer-indexed.

Sign up to request clarification or add additional context in comments.

Comments

0

The below is the example:

$obj = new stdClass;
$obj->{'1'} = 1;
$arr = (array) $obj;
var_dump($arr);
var_dump(isset($arr[1]));  // will get false

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.