Advertisement

SQL to PHP array converter

Convert SQL to PHP array free in your browser. Paste your SQL INSERT on the left, press Convert, and copy clean PHP array on the right. No sign-up, no uploads.

Converter

Paste SQL INSERT below, press Convert, and copy the PHP array output.

Advertisement

How SQL becomes PHP array

The parser reads each INSERT INTO statement, takes the column list in parentheses as the headers, then walks every VALUES tuple and pairs each value with its column. Quoted strings are unescaped, NULL becomes a true null, and numbers and booleans keep their types, so the PHP array output reflects the real data types instead of turning everything into text.

Tips for the PHP output

The snippet assigns $data, so rename the variable or wrap it in a return statement if you are building a config file. It is also a quick way to seed Laravel or WordPress fixtures: convert, paste into a seeder, and the nested array() syntax works on every supported PHP version.

SQL to PHP array FAQs

How should my SQL INSERT statements look?
Paste one or more INSERT INTO statements with an explicit column list, like INSERT INTO users (id, name) VALUES (1, 'Ana'), (2, 'Ben');. Quoted strings, numbers, NULL, TRUE and FALSE are all understood, and several statements can be converted in one go. Statements without a column list are rejected so the PHP array columns stay accurate.
Is the PHP output valid code I can run?
Yes. It prints a complete <?php snippet assigning $data with classic array() syntax, single-quoted strings with escaping, and null/true/false literals. Paste it straight into any PHP 5.4+ project. Nested values from SQL fields are rendered as nested arrays.
Do multiple tables in one paste stay separate?
All INSERT statements are merged into one row set using the union of their columns, with empty cells where a table lacks a column. If you need per-table PHP array, convert each table's statements separately for the cleanest result.
Is there a size limit for SQL input?
No hard limit, but everything runs in your browser tab, so tens of thousands of rows convert in seconds while millions of rows may slow the page. For very large SQL files, split them into smaller chunks and convert each separately.
Is my SQL data private, and who uses this?
Yes. The conversion runs 100% in your browser; nothing is uploaded to any server. Developers, analysts and DBAs use it to move SQL data into PHP array for migrations, reports and config work without installing anything.
Advertisement