In PHP, pushing a value inside an array automatically creates a numeric key for itself. When you are adding a value-key pair, you actually already have the key, so, pushing a key again does not make sense. You only need to set the value of the key inside the array. Here’s an example to correctly push a [air pf value and key inside an array:

$data = array(
   "name" => "Best Interview Questions"
);

array_push($data['name'], 'Best Interview Questions');

Now, here to push “cat” as a key with “wagon” as the value inside the array $data, you need to do this:

$data['name']='Best Interview Questions';

BY Best Interview Question ON 15 Apr 2020