Page 1 of 1

variable as array...get the data inside one

Posted: Fri Dec 20, 2002 4:54 pm
by Next_Gate
I have this code in a file:

Code: Select all

$var = array ( 
     'varName1'  =>  "Hello Wolrd 1",
     'varName2'  =>  "Hello Wolrd 2",
     'varName3'  =>  "Hello Wolrd 3"
)
So i know that i can call the variable $var like this:

Code: Select all

$string = $varї'varName1']
but i need to know if its possible to call it by position.. for example varName1 = 0
varName2 = 1
varName3 = 2

bu t i have trie to do this and doesnt work $string = $var[0]

and the variable string doesnt take anything....

Any of you could help me please??

Thanks

Posted: Sat Dec 21, 2002 9:32 am
by Johnm
Change $string = $var[0] to $string = $var['0'] and see if that works.

John M

Posted: Sat Dec 21, 2002 10:42 am
by Next_Gate
already done.. with this:

Code: Select all

$newArray = array_values($array);
then you invoque like this:

Code: Select all

$newArrayїnumericValue]
Thats it.. it was much easier that i thought!!..ajja