|
Posted by Norman Peelman on 12/01/06 12:48
"Ira Gladnick" <IraGladnick@yahoo.com> wrote in message
news:1164951377.341133.224300@n67g2000cwd.googlegroups.com...
> I have found that in PHP 5, <?php $SomeArray{0} = $somevalue ?> (note
> the squigly braces) appears to be functionally equivalent to the more
> usual <?php $SomeArray[0] = $somevalue ?> (square array brackets).
>
> However, doing $SomeArray{} = $somevalue raises an error.
>
> I can't seem to find any documentation that indicates why you can use
> squigly braces in the case where an array index is provided. Was
> wondering if someone could explain why they work in that situation, and
> possibly provide a reference to this use of squigly braces in the PHP 5
> documentation.
>
> (I am a rank PHP newbie, for whatever that's worth..)
>
You use [ ] on arrays such as:
$someArray[0] = "0123456789";
$someArray[1] = "rock 'n roll";
echo $someArray[0] will output:
0123456789
echo $someArray[1] will output:
rock 'n roll
You use { } on strings such as:
$someString1 = "0123456789";
$someString2 = "rock 'n roll";
echo $someString1{5} will output:
5
echo $someString2{3} will output:
k
strings are zero based... with this method you can manipulate strings at the
character level if you want.
Norm
--
FREE Avatar hosting at www.easyavatar.com
Navigation:
[Reply to this message]
|