How to convert multi-dimensional array key to string type

PHP convert multi-dimention array all keys to type string from numeric type. If found issue/fatal error/warning with numeric type array keys in php or php7 use below simple one line code to convert array keys to string type.

Convert multi-dimention array key to string type

$arr = unserialize( serialize( $arr ) );

Process for convert multi-dimention array key to string type

  • serialize array first
  • serialize convert array in serialize string format
  • unserialize again serialize output string
  • unserialize convert serialize string to array with all string type key