|
-
Nov 17th, 2004, 05:31 PM
#1
Thread Starter
Ex-Super Mod'rater
Creating Arrays -[RESOLVED]-
How do I make arrays, inparticular the ones that use strings instead of indexes .
Last edited by Electroman; Nov 17th, 2004 at 05:55 PM.
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
Nov 17th, 2004, 05:33 PM
#2
PHP Code:
Array ('index1' => 'value1', 'index2' => 'value2', 'index3' => 'value3');
-
Nov 17th, 2004, 05:34 PM
#3
Thread Starter
Ex-Super Mod'rater
How about adding to an array after it was first created, or must you clear it and make a new one for that?
Also how about Multidimensional ones .
P.S. that was quick .
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
Nov 17th, 2004, 05:42 PM
#4
The reply was even quicker .
There are hundreds of array functions that do just about everything you can hope for with array manipulation. You have functions like array_pop() and array_push() that let you turn it into a stack, you have merging functions, traversing functions, sorting functions, combining functions, adding functions, padding functions, callback functions ....
ok you get my drift, heres the full list.
http://uk2.php.net/manual/en/ref.array.php
Multi dimensional arrays are made by putting one array inside another.
PHP Code:
Array (Array(1,2,3,4,5), Array(3,4,5,6,7));
To add a value to an array which has already been initialized, just omit the index:
PHP Code:
$array = Array(1,2,3,4);
$array[] = 5;
-
Nov 17th, 2004, 05:44 PM
#5
Frenzied Member
PHP Code:
$main_list = array();
$main_list[0] = "Home";
$main_list[1] = "PHP";
$main_list[2] = "Links";
$main_list[3] = "Contact";
for multi dimensional:
PHP Code:
$smt = array();
$smt [0] = array("one","two");
$smt [1] = array("abc","def");
$smt [2] = array("123","456");
$smt [3] = array("alpha","omega");
to call something from a one dimensional array use: to call something from a multi dimensional array use:
PHP Code:
$main_list[0][0]
to see how many items in an array do
PHP Code:
count($arrayname)
edit: at least that is my neat and readable (for me) way of doing things.
Have I helped you? Please Rate my posts. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|