You are here: Re: Create array (really basic) « All PHP « IT news, forums, messages
Re: Create array (really basic)

Posted by J.O. Aho on 07/31/05 19:07

paul wrote:
> Sorry, I just haven't done this manually, here's what I want:
>
> $array=
> key,initial,name
> 0,"C","Geoff C."
> 1,"V","Pete V."
> 2,"F","Paul F."
>
> I fumbled around at php.net for a while without finding such a basic thing.

$array=array(array("initial" => "C", "name" => "Geoff C."),
array("initial" => "V", "name" => "Peter V."),
array("initial" => "F", "name" => "Paul F.")
);
http://www.php.net/manual/en/function.array.php

Gives you a array that looks like this:
Array
(
[0] => Array
(
[initial] => C
[name] => Geoff C.
)
[1] => Array
(
[initial] => V
[name] => Peter V.
)
[2] => Array
(
[initial] => F
[name] => Paul F.
)
)

To access data you use

$array[key_number]['initial']

or

$array[key_number]['name']

replace the "key_number" with the number you want to access.



//Aho

 

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

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