Runs locally in your browser

Convert a List to a PHP Array

Generate a PHP short-syntax string array with configurable quotes, variable name, layout, and PHP-aware escaping.

Input → Result

Turn plain lines into a PHP array assignment or literal.

Options
PHP array0 items

About this tool

Convert a List to a PHP Array

PHP arrays are common in configuration, allowlists, migrations, and test data. Hand-formatting becomes risky when values contain apostrophes, backslashes, or dollar signs.

Single-quoted and double-quoted output follow different PHP escaping rules, including dollar-sign escaping in interpolated double-quoted strings.

FAQ

Frequently asked questions

Should the variable name include a dollar sign?+

Either form works. Enter items or $items and the output will contain one leading dollar sign.

Why are dollar signs escaped in double quotes?+

PHP interpolates variables inside double-quoted strings, so escaping preserves the literal dollar sign.

Related tools

Popular list tools

Browse all tools →

Guides

Related guides

Guides →