MediaWiki to PHP Converter
Transform MediaWiki tables into PHP arrays for web development
MediaWiki Input
PHP Output
About MediaWiki to PHP Converter
Convert MediaWiki table markup to PHP arrays with multiple format options. Perfect for web development, data processing, and integrating wiki data into PHP applications.
Key Features
- Multiple Formats: Indexed, associative, or multidimensional arrays
- Type Detection: Automatically detects integers, floats, booleans, null, and strings
- Key Sanitization: Converts headers to valid PHP array keys
- Custom Variable Names: Choose your array variable name
- PHP Tags: Optional PHP opening and closing tags
- Proper Escaping: Safely escapes special characters in strings
- Copy & Download: Easy integration into PHP projects
How to Use
- Input MediaWiki Table: Paste your MediaWiki table markup or upload a .wiki file
- Choose Format: Select your preferred array format
- Configure Options: Set variable name and PHP tag preferences
- Copy or Download: Use the PHP code in your application
Array Formats
- Indexed Array: Simple numeric-indexed array with headers as first row
- Associative Array: Array of associative arrays with column names as keys
- Multidimensional Array: Separate headers and rows arrays with structured format
Example Conversion
MediaWiki Input:
{| class="wikitable" border="1"
! Name !! Age !! City !! Salary
|-
| John Doe || 28 || New York || 75000
|-
| Jane Smith || 34 || London || 82000
|} PHP Output (Associative Array):
<?php
$data = [
['Name' => 'John Doe', 'Age' => 28, 'City' => 'New York', 'Salary' => 75000],
['Name' => 'Jane Smith', 'Age' => 34, 'City' => 'London', 'Salary' => 82000]
];
?> Common Use Cases
- Web Development: Import wiki data into PHP web applications
- CMS Integration: Use wiki tables in WordPress, Drupal, or custom CMS
- Data Processing: Process wiki data with PHP scripts
- API Development: Convert wiki tables to PHP arrays for APIs
- Database Seeding: Create seed data for PHP/MySQL applications
- Configuration Files: Generate PHP configuration arrays from wiki tables
Type Detection
Automatically detects and converts data types:
- Integers: Whole numbers (e.g., 42, -10)
- Floats: Decimal numbers (e.g., 3.14, -0.5)
- Booleans: true/false values
- Null: Empty cells or null values
- Strings: Text values with proper escaping
Key Sanitization
Converts MediaWiki headers to valid PHP array keys:
- Replaces special characters with underscores
- Ensures keys don't start with numbers
- Removes duplicate underscores
- Provides fallback keys if needed
PHP Array Operations
Once converted, you can use all PHP array functions:
// Access data
echo $data[0]['Name']; // John Doe
// Loop through array
foreach ($data as $row) {
echo $row['Name'] . ': ' . $row['Salary'] . "\n";
}
// Filter data
$filtered = array_filter($data, function($row) {
return $row['Age'] > 30;
});
// Sort by column
usort($data, function($a, $b) {
return $b['Salary'] - $a['Salary'];
}); Format Comparison
- Indexed Array: Best for simple data iteration, smallest code size
- Associative Array: Best for named column access, most readable
- Multidimensional Array: Best for separate header/data processing, most flexible
Privacy & Security
All conversions happen locally in your browser. Your MediaWiki data is never uploaded to any server, ensuring complete privacy and security.
