3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $obj = new \StdClass; $obj->textfield->id = 'text12'; $obj->textfield->text = 'herro'; $anotherObj = new \StdClass; $anotherObj->textfield->id = 'text1'; $anotherObj->textfield->text = 'moarrr text'; $yesAnother = new \StdClass; $yesAnother->textfield->id = 'text11'; $yesAnother->textfield->text = 'omggggg'; $array = array($obj, $anotherObj, $yesAnother); usort($array, function($a, $b) { preg_match_all('#\d+#', $a->textfield->id, $matchesA); preg_match_all('#\d+#', $b->textfield->id, $matchesB); $idNumA = (int)$matchesA[0][0]; $idNumB = (int)$matchesB[0][0]; return $idNumA > $idNumB; }); var_dump($array);
based on O0da1
Output for 5.4.0 - 7.1.0
Warning: Creating default object from empty value in /in/l2lcf on line 4 Warning: Creating default object from empty value in /in/l2lcf on line 8 Warning: Creating default object from empty value in /in/l2lcf on line 12 array(3) { [0]=> object(stdClass)#3 (1) { ["textfield"]=> object(stdClass)#4 (2) { ["id"]=> string(5) "text1" ["text"]=> string(11) "moarrr text" } } [1]=> object(stdClass)#5 (1) { ["textfield"]=> object(stdClass)#6 (2) { ["id"]=> string(6) "text11" ["text"]=> string(7) "omggggg" } } [2]=> object(stdClass)#1 (1) { ["textfield"]=> object(stdClass)#2 (2) { ["id"]=> string(6) "text12" ["text"]=> string(5) "herro" } } }
Output for 5.3.0 - 5.3.29
Strict Standards: Creating default object from empty value in /in/l2lcf on line 4 Strict Standards: Creating default object from empty value in /in/l2lcf on line 8 Strict Standards: Creating default object from empty value in /in/l2lcf on line 12 array(3) { [0]=> object(stdClass)#3 (1) { ["textfield"]=> object(stdClass)#4 (2) { ["id"]=> string(5) "text1" ["text"]=> string(11) "moarrr text" } } [1]=> object(stdClass)#5 (1) { ["textfield"]=> object(stdClass)#6 (2) { ["id"]=> string(6) "text11" ["text"]=> string(7) "omggggg" } } [2]=> object(stdClass)#1 (1) { ["textfield"]=> object(stdClass)#2 (2) { ["id"]=> string(6) "text12" ["text"]=> string(5) "herro" } } }
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/l2lcf on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/l2lcf on line 7 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/l2lcf on line 11 Parse error: syntax error, unexpected T_FUNCTION in /in/l2lcf on line 17
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/l2lcf on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/l2lcf on line 7 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/l2lcf on line 11 Parse error: parse error, unexpected T_FUNCTION in /in/l2lcf on line 17
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/l2lcf on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/l2lcf on line 7 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/l2lcf on line 11 Parse error: parse error in /in/l2lcf on line 17
Process exited with code 255.