Link to home
Start Free TrialLog in
Avatar of deharvy
deharvy

asked on

Adding Values to an Array

How can I add a key/value set to an array?

I tried using array_push, but it doesn't seem to be working. Here is what I tried:

$string = "300=>null";
$data = array( '200'=>null );
array_push($data, $string );
print_r($data);

My results are:

Array ( [200] => [201] => '300'=>null )

I'd like my results to be:

Array ( [200] => [300] => )

Any assistance is greatly appreciated.
ASKER CERTIFIED SOLUTION
Avatar of Aaron Tomosky
Aaron Tomosky
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of deharvy
deharvy

ASKER

Works like a charm. Thanks!