Reputation: 1447
I need to set a variable = to an array element. $var = $ary[1]; does not work. ary[1]= "test". If that helps
Upvotes: 1
Views: 22664
Reputation: 1612
confirm that your first initialize the array variable before using it like:
$ary=array();
Try this:
$ary[]= $var;
must use $
sign for var/arrays in php and you don't require 1 if a single value is inserted..
Upvotes: 2
Reputation: 89
PHP arrays are zero indexed, that may be your problem
$ary = array("test");
$var = $ary[0]
$var == "test"
Upvotes: 5
Reputation: 30238
This is the way to set a variable with array elemen.
why it is not working , please check your array content .
http://php.net/manual/en/language.types.array.php
Upvotes: 0