You are here: Re: confused on arrays « All PHP « IT news, forums, messages
Re: confused on arrays

Posted by Tom on 11/05/07 18:45

On Sun, 04 Nov 2007 07:37:22 +0100, J.O. Aho wrote...
>
>ja wrote:
>>> The brackets are used to access a particular element of an array or a
>>> character in a string.
>
>> So the bracket is used only when I need to access whatever is contained in
>> the array while parents are used to construct them? Do I have it somewhat
>> correct?
>
>No, not only,
>
>assign new values to an array
>
>$array[]='somthing';
>
>which is equal to (using the functions array_push())
>
>array_push($array,'something');
>
>
>and of course you can access the content on an array by specifying a cell
>
>echo $array[0];
>
>keep in mind that in an array, 0 is the first cell and 1 is the second one.
>
>

You can use numeric values in the brackets to create a scalar array...

$array[0] = 'first';
$array[1] = 'second';

of you can create associative arrays for key/value pairs, such as ...

$array['age'] = 18;
$array['date'] = '2007-11-05';

Depending on your application, one may be more useful that the other.

Tom
--
NewsGuy Free Trial Accounts
Now a massive 20 Gigabytes of unrestricted downloads !
http://newsguy.com/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация