I think the best way to do this would be ...
$one[] = $two[] = 'hello';
He works!
Update
BTW Any answers using array_push? - Trufa
Of course.
$value = 'hello'; array_push($one, $value); array_push($two, $value);
Although I would say that using the [] syntax is easier :)
If you want to add multiple elements to an array, it may be easier to use array_merge() .
$one = array_merge($one, array( 'a', 'b', 'c' ));
You can also use + array operaror , but it acts differently (for example, it will not overwrite string keys from the left operand array_merge() will be).
$one += array( 'a', 'b', 'c' );
alex
source share