3v4l.org

run code in 500+ PHP versions simultaneously
<?php $db = new PDO('sqlite::memory:'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $db->exec('CREATE TABLE example (name TEXT, vals TEXT);'); $insert = $db->prepare('INSERT INTO example (name, vals) VALUES (?, ?)'); $insert->execute(array('row1', '1,3,4')); $insert->execute(array('row2', '1')); $insert->execute(array('row3', '5,6')); function csv_intersection($vals, $search) { $vals_array = explode(',', $vals); $search_array = explode(',', $search); $intersection = array_intersect($vals_array, $search_array); return implode(',', $intersection); } $db->sqliteCreateFunction('intersection', 'csv_intersection', 2); $stmt = $db->prepare('SELECT name, vals FROM example WHERE intersection(vals, ?)'); $stmt->execute(array('1,2,3')); foreach ($stmt as $row) { var_dump($row); }
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { ["name"]=> string(4) "row1" ["vals"]=> string(5) "1,3,4" } array(2) { ["name"]=> string(4) "row2" ["vals"]=> string(1) "1" }

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:
66.08 ms | 1418 KiB | 4 Q