PDA

View Full Version : New discovery !


bahytq
05-11-2003, 08:11 PM
I have found this so interesting ? Have anyone known this before ?
PHP doesnot allow us to insert values of a kind of an Associative array into that kind of array . It just let us insert as constant like

$arr = array("a1"=>'value1',"a2"=>'value2'....);

Till now i found no way of adding new value to this array $arr although i did try with array_Push() or next($array) .
Have anyone found this before ?

mordred
05-12-2003, 01:31 AM
Adding new values to an associative array is absolutely no issue:


$arr = array("a1"=>'value1',"a2"=>'value2');
array_push($arr, "value3");
var_dump($arr);

$arr['a4'] = 'value4';
var_dump($arr);


As you can see from the output, the content of the array has changed like expected. Does that answer your question?