3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( 'a' => 'va', 'b' => 'vb', 'c' => 'vc', ); $sql = "INSERT INTO Post(" . implode(', ', array_keys($arr)) . ") VALUES ('" . implode("', '", $arr) . "');"; echo "$sql\n"; $sql = "INSERT INTO Post("; $columns = $values = ''; foreach ($arr as $column => $value) { $columns .= "$column, "; $values .= $value ? "'$value', " : "NULL, "; } $sql .= trim($columns, ', ') . ") VALUES (" . trim($values, ', ') . ");"; echo "$sql\n"; $cols = count($arr); $keys = array_keys($arr); $sql = "INSERT INTO Post("; $columns = $values = ''; for ($c = 0; $c < $cols; $c++) { $key = $keys[$c]; $columns .= $key; $values .= $arr[$key] ? "'{$arr[$key]}'" : "NULL"; if ($c < $cols - 1) { $columns .= ', '; $values .= ', '; } } $sql .= "$columns) VALUES ($values);"; echo "$sql\n";
Output for git.master, git.master_jit, rfc.property-hooks
INSERT INTO Post(a, b, c) VALUES ('va', 'vb', 'vc'); INSERT INTO Post(a, b, c) VALUES ('va', 'vb', 'vc'); INSERT INTO Post(a, b, c) VALUES ('va', 'vb', 'vc');

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
118.59 ms | 405 KiB | 5 Q