SQL DDL to PHP Array Converter
Parse CREATE TABLE statements to extract column names, types, lengths, default values and comments, then generate a ready-to-paste PHP array definition.
About This Tool
The SQL DDL to PHP array tool parses CREATE TABLE statements, extracting column names, types, lengths, nullability, defaults, auto increment, unsigned flags and comments, then assembles a ready-to-paste PHP array. Field lists often have to be repeated across models, forms and validation rules, and retyping them is slow and error prone.
The parser handles backtick-quoted identifiers, separate and inline PRIMARY KEY declarations, skips index lines automatically and picks up the table-level COMMENT. Output includes a comment header with the table name and comment so it is clear where the array came from.
Key Features
Complete column info
Type, length, nullability, default, auto increment, unsigned and comments.
Index lines skipped
KEY, UNIQUE and CONSTRAINT lines never leak into the column list.
Source in comment
Generated output includes the table name and comment for traceability.
Style options
array() or [] syntax with 2, 4 or 8 space indentation.
When to Use It
Initialise model fields
Turn a CREATE TABLE statement into model field definitions directly.
Generate form config
Use columns and their comments as form labels and field settings.
Document schemas
Export the database structure as a PHP array for API documentation.
How to Use It
- 1Paste a complete CREATE TABLE statement.
- 2Choose array syntax and indentation width.
- 3Click Convert to PHP.
- 4Copy the result into your project file.
Frequently Asked Questions
Does it support ALTER TABLE?
No. The tool focuses on CREATE TABLE; convert other statements into a table definition first.
Are enum and decimal types parsed?
Yes. Parenthesised types keep their full content, such as enum('a','b') and decimal(10,2).
