# assign to object by offset

- Thread: https://externals.io/message/7538
- Original archive: https://news-web.php.net/php.internals/7538
- Started by Rob Richards on 2004-02-04T14:17:13+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #7538 — Rob Richards — 2004-02-04T14:17:13+00:00

URL: https://externals.io/message/7538#7538

Is there any reason that zend_assign_to_object always converts the property to a string when it's a variable?

Looking at simpexml, there is no way to distinguish between writing to an element or to an attribute when using variables.
$sxe[0] = "a"; works fine, but $i=0; $sxe[$i] = "a"; doesnt as $i is sent to the write_dimension function as a string while 0 is passed as is.
Due to this $sxe[0] will write the value to the element, while $sxe[$i] will write it to the attribute.

Reading however works fine as no conversion is done on the zval.

Thanks,

Rob
