JSON Input Area
PHP Array Code

PHP Array Conversion Guide & Syntax Info

Tool Features

  • Short Array Syntax Support: You can toggle between PHP 5.4+ [] syntax and traditional PHP 5.3 array() syntax with one click using the "Use Short Array []" button at the top.
  • Auto Escaping: When strings in JSON contain single quotes (e.g., O'Reilly), the tool automatically escapes them to O\'Reilly to prevent syntax errors in the generated PHP code.
  • Structure Restoration: Both Objects and Arrays in JSON are uniformly converted into PHP Associative Arrays and Indexed Arrays.

PHP Array Features

  • Universal Data Structure: Unlike many static languages, a PHP Array is essentially an Ordered Map, which can act as a list, hash table, dictionary, collection, and stack simultaneously.
  • Type Mapping: JSON's true/false/null will be mapped to PHP's native true/false/null keywords (without quotes).