Markdown To PHP Array

Login

Email
Password

Don't have an account yet?

Go to Sign up

Input Data
Sample {{ showCoderInput ? 'Choose File' : 'Enter Data' }}

                                
Valid Data Invalid Data — Cannot parse as table
Online Table Editor
Row Col Row Col
Transpose Clear Delete Empty Deduplicate
ABC abc Abc
Replace
First Row as Header
{{ displayRows.length }} rows x {{ displayHeaders.length }} columns{{ firstRowAsHeader ? ' (1 header)' : '' }} {{ selectedRows.length > 0 ? selectedRows.length + ' selected' : '' }}
Output Data ({{ outputFormatDisplayName }})
{{ copied ? 'Copied!' : 'Copy to Clipboard' }} Download File
Properties
Convert Markdown Table to PHP online — paste, edit, and download.

Convert Restart
Insert Row Below
Insert Row Above
Insert Column Right
Insert Column Left
Delete Row {{ contextMenu.row + 1 }}
Delete Column {{ contextMenu.col + 1 }}
Clear Cell
Clear Row
Case sensitive Use regex Cancel Replace All

What Is the Markdown To PHP Array Converter?

The Markdown To PHP Array Converter on A.Tools transforms Markdown pipe-delimited tables into valid PHP array code — ready to paste into Laravel config files, database seeders, WordPress templates, or any PHP project. All processing runs in your browser. No data leaves your device.

Tabular data is often documented in Markdown tables within README files, design specs, and wikis. PHP uses arrays as its primary data structure for configuration, data transfer, and templating. This tool converts between the two without manual typing.

How to Convert Markdown Tables to PHP Arrays?

Step 1: Provide Your Markdown Data

Click Enter Data to paste a Markdown table into the input area, or click Choose File to drag and drop a .md file. Press Sample to load example data.

Step 2: Edit in the Online Table Editor

Once parsed, an interactive spreadsheet appears. Use the toolbar to:

  • Add or delete rows and columns

  • Transpose the table (swap rows and columns)

  • Remove duplicate rows

  • Delete empty rows and columns

  • Change text case (UPPERCASE, lowercase, Capitalize)

  • Find and replace values — supports case-sensitive search and regex

  • Toggle First Row as Header to define array keys

Right-click any cell for context-menu operations.

Step 3: Export

Click Convert to generate PHP array code. Use Copy to Clipboard or Download File to save as a .php file.

Key Features

  • Two input modes: Paste Markdown directly or upload a .md file via drag-and-drop

  • Full table editor: Edit, transpose, deduplicate, find-and-replace before converting

  • Client-side processing: Files never leave the browser — zero data upload

  • Undo/Redo: Full edit history with revert support

  • Context menu: Right-click for quick row/column/cell operations

  • Header toggle: Treat the first row as associative array keys or generate indexed output

  • Validation indicator: Real-time feedback on input validity

What the Output Looks Like

Given this Markdown input:

| name  | age | city        |
|-------|-----|-------------|
| Alice | 30  | New York    |
| Bob   | 25  | Los Angeles |

The tool generates:

array(
   array(
       'name' => 'Alice',
       'age' => '30',
       'city' => 'New York'
   ),
   array(
       'name' => 'Bob',
       'age' => '25',
       'city' => 'Los Angeles'
   )
)

Key output characteristics

  • Each data row becomes a nested associative array() using header values as keys

  • All values are wrapped in single-quoted strings

  • The outer structure is an indexed array of associative arrays

  • The output uses the classic array() syntax for maximum PHP version compatibility

Header Mode vs. Flat Mode

With First Row as Header enabled (default), the output uses header values as associative keys. With it disabled, the output generates indexed arrays:

array(
   array(
       0 => 'name',
       1 => 'age',
       2 => 'city'
   ),
   array(
       0 => 'Alice',
       1 => '30',
       2 => 'New York'
   ),
   array(
       0 => 'Bob',
       1 => '25',
       2 => 'Los Angeles'
   )
)

Understanding PHP Array Syntax

PHP arrays are the language's primary compound data structure. They function as ordered maps — combining the behavior of lists, dictionaries, queues, and stacks in other languages.

The two syntax forms

PHP supports two array declaration syntaxes:

// Traditional syntax (PHP 4+)
$arr = array('a', 'b', 'c');

// Short syntax (PHP 5.4+)
$arr = ['a', 'b', 'c'];

Both are equivalent. The tool outputs the traditional array() syntax for maximum compatibility.

Array functions commonly used with tabular data

FunctionPurpose
array_column()Extract a single column from an array of arrays
array_map()Apply a function to every element
array_filter()Remove elements that don't match a condition
array_merge()Combine two or more arrays
array_keys()Get all keys from an array
array_values()Get all values, re-indexing numerically
array_unique()Remove duplicate values
sort() / usort()Sort arrays by value or custom comparator
count()Count elements in an array
in_array()Check if a value exists in an array
json_encode()Convert array to JSON string

Official documentation: PHP Array Types

Indexed Arrays vs. Associative Arrays

Indexed arrays

Indexed arrays use automatic numeric keys starting from 0:

$cities = array('New York', 'Los Angeles', 'Chicago');

echo $cities[0]; // "New York"
echo $cities[1]; // "Los Angeles"

Associative arrays

Associative arrays use named string keys:

$person = array(
   'name' => 'Alice',
   'age' => 30,
   'city' => 'New York'
);

echo $person['name']; // "Alice"
echo $person['age'];  // 30

The tool's default output: array of associative arrays

The converter generates a structure commonly used for tabular data in PHP — an indexed outer array where each element is an associative array representing one row:

$data = array(
   array('name' => 'Alice', 'age' => '30'),
   array('name' => 'Bob', 'age' => '25')
);

// Access a specific cell
echo $data[0]['name']; // "Alice"

// Loop through all rows
foreach ($data as $row) {
echo $row['name'] . ' is ' . $row['age'];
}

// Extract one column
$names = array_column($data, 'name');
// ['Alice', 'Bob']

This structure is the standard format used by PDO fetchAll(), Laravel Eloquent collections, and WordPress query results.

Use Cases: When to Convert Markdown to PHP

ScenarioWhy Convert
Laravel config filesGenerate config/ array files from documented settings
Database seedersCreate DatabaseSeeder.php arrays from spec tables
WordPressGenerate option arrays for themes and plugins
Form definitionsConvert form spec tables into validation rule arrays
Data fixturesCreate test data arrays for PHPUnit tests
Menu/navigationConvert sitemap tables into nested array structures
API response mocksGenerate static response data from documented examples
Migration dataMove documented data into Laravel migration files

Laravel Config Example

// config/services.php
return array(
   array(
       'name' => 'Stripe',
       'driver' => 'stripe',
       'key' => 'pk_test_123'
   ),
   array(
       'name' => 'PayPal',
       'driver' => 'paypal',
       'key' => 'sandbox_456
   '
)
);

Laravel Seeder Example

// database/seeders/UserSeeder.php
$users = array(
   array(
       'name' => 'Alice',
       'email' => '[email protected]',
       'role' => 'admin'
   ),
   array(
       'name' => 'Bob',
       'email' => '[email protected]',
       'role' => 'editor'
   )
);

foreach ($users as $user) {
   DB::table('users')->insert($user);
}

WordPress Shortcode Example

// shortcode handler
$products = array(
   array('sku' => 'A100', 'price' => '29.99', 'stock' => '50'),
   array('sku' => 'B200', 'price' => '49.99', 'stock' => '30')
);

$output
= '<table>';
foreach ($products as $product) {
   $output .= '<tr>';
   $output .= '<td>' . $product['sku'] . '</td>';
   $output .= '<td>' . $product['price'] . '</td>';
   $output .= '</tr>';
}
$output .= '</table>';
return $output;

Frequently Asked Questions (FAQ)

  • Does this tool upload my files to a server?

    No. All file parsing and conversion runs in your browser using JavaScript. Your data stays on your device. A.Tools never receives, stores, or transmits your file contents.

  • What Markdown table formats are supported?

    The tool supports standard pipe-delimited Markdown tables following the CommonMark specification, including tables with or without leading/trailing pipes and alignment indicators.

  • What does the PHP output look like?

    The tool generates an indexed array of associative arrays. Each data row becomes a nested array() with header values as keys. See the "What the Output Looks Like" section above for examples.

  • Is the output valid PHP syntax?

    Yes. The generated code uses the array() syntax compatible with PHP 4 through PHP 8.x. It can be pasted directly into any .php file.

  • Are all values generated as strings?

    Yes. All cell values are wrapped in single-quoted strings. Use PHP type casting ((int), (float), (bool)) in your application code to convert types as needed.

  • Why does the tool use array() instead of []?

    The traditional array() syntax is compatible with all PHP versions (4+). The short syntax [] requires PHP 5.4+. You can perform a find-and-replace to convert array( to [ and closing ) to ] if your project requires short syntax.

  • Can I edit the table before converting?

    Yes. After parsing, the full table editor lets you modify cells, add or remove rows and columns, transpose, deduplicate, change text case, and find-and-replace values.

  • Is there a file size limit?

    Processing is client-side, so the limit depends on your browser's memory. Tables with tens of thousands of rows work reliably on modern browsers.

Featured Tools

Featured tools that you might find useful.

Popular Tools

List of popular tools that users love and frequently use.

New Tools

The latest tools added to our collection, designed for you.

Topics

The tools grouped by topics to quickly find what you need.
Free online Excel to JSON converter. Transform XLSX, XLS, XLSM files into JSON arrays, objects, or keyed formats instantly in your browser — no upload, 100% private.

Excel To JSON

Free online Excel to JSON converter. Transform XLSX, XLS, XLSM files into JSON arrays, objects, or keyed formats instantly in your browser — no upload, 100% private.
Free Excel to CSV converter. Convert XLSX, XLS, XLSM to CSV instantly in your browser. No upload, 100% private. Edit, transpose, deduplicate before exporting.

Excel To CSV

Free Excel to CSV converter. Convert XLSX, XLS, XLSM to CSV instantly in your browser. No upload, 100% private. Edit, transpose, deduplicate before exporting.
Free online Excel to SQL converter. Generate CREATE TABLE and INSERT statements from spreadsheets for MySQL, PostgreSQL, SQLite, and SQL Server. Supports batch insert, primary keys, and type inference.

Excel To SQL

Free online Excel to SQL converter. Generate CREATE TABLE and INSERT statements from spreadsheets for MySQL, PostgreSQL, SQLite, and SQL Server. Supports batch insert, primary keys, and type inference.
Free online Excel to ASCII table converter with 10 border styles (MySQL, Unicode, reStructuredText, and more). Add code comment wrappers in 8 languages. Supports text alignment. Client-side processing.

Excel To ASCII Table

Free online Excel to ASCII table converter with 10 border styles (MySQL, Unicode, reStructuredText, and more). Add code comment wrappers in 8 languages. Supports text alignment. Client-side processing.