How to push both value and key into PHP array

Nope, there is no array_push() equivalent for associative arrays because there is no way determine the next key.

You’ll have to use

$arrayname[indexname] = $value;

Leave a Comment