-1

I want to add a key and value in the array as first element without impacting other elements

Array
(
[8] => ab
[10] => cd
[11] => ef
[9] => gh
[7] => ik
)

Resultant array should be

Array
(
[0] => All
[8] => ab
[10] => cd
[11] => ef
[9] => gh
[7] => ik
)

 

1 Answers1

0

Use array_unshift.

array_unshift(‘All’);
JoelCrypto
  • 462
  • 2
  • 12