3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array(array("id" => 1,"title" => "Hello World", "body" => "Hi Jude All this is my content"), array("id" => 2,"title" => "Hello World Boy", "body" => "Hi All this is my content Girl"), array("id" => 3,"title" => "Hello Kids", "body" => "Hi All this is my content Kid"), array("id" => 4,"title" => "Hello World Jude", "body" => "Hi All this is my content Jude"), array("id" => 5,"title" => "Hello World Jude January", "body" => "Hi All this is my content Jan"), array("id" => 6,"title" => "Hello World January June Lord", "body" => "Hi All this is my content Jan Jude Lord")); $str = "Hello world January jude"; function sort_most_needles(&$array, $str) { $needles = explode(" ", $str); usort($array, fn($a, $b) => array_uintersect($needles, explode(" ", $b['title']), 'strcasecmp') <=> array_uintersect($needles, explode(" ", $a['title']), 'strcasecmp') ); } sort_most_needles($arr, $str); var_export($arr);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'id' => 5, 'title' => 'Hello World Jude January', 'body' => 'Hi All this is my content Jan', ), 1 => array ( 'id' => 6, 'title' => 'Hello World January June Lord', 'body' => 'Hi All this is my content Jan Jude Lord', ), 2 => array ( 'id' => 4, 'title' => 'Hello World Jude', 'body' => 'Hi All this is my content Jude', ), 3 => array ( 'id' => 1, 'title' => 'Hello World', 'body' => 'Hi Jude All this is my content', ), 4 => array ( 'id' => 2, 'title' => 'Hello World Boy', 'body' => 'Hi All this is my content Girl', ), 5 => array ( 'id' => 3, 'title' => 'Hello Kids', 'body' => 'Hi All this is my content Kid', ), )

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:
104.67 ms | 407 KiB | 5 Q