Having a C background I was surprised that there was something like $str{1}. Strings were either objects or an array of chars for me. Why bother to add more special symbols for accessing a single element of a string?astions wrote:I don't agree with that at all. Brackets should strictly be reserved for array indexes and braces should be strictly reserved for string offsets.
Did you know that {} and [] are completely interchangeable?
Code: Select all
$arr = array('abc', new stdClass);
ecno $arr[0][1], "\n";
echo $arr{1}->prop = 1234;
print_r($arr);Code: Select all
$arr = array('abc', 'xyz');
echo $arr[1][1];Code: Select all
$arr = array('abc', 'xyz');
echo substr($arr[1], 1 ,1);I'd ask Zeev SuraskiThese people are nuts. Who can I gripe to?