3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test() { $orderedids=array(7, 9, 5, 3); $tags=array( new Tag(3), new Tag(7), new Tag(5), new Tag(9) ); $flipped=array_flip($orderedids); return usort($tags, function($tag1, $tag2) { if $flipped[$tag1->id]<$flipped[$tag2->id] return -1; else if $flipped[$tag1->id]==$flipped[$tag2->id] return 0; else return 1; }); } class Tag { public $id; function __construct($id) { $this->id=$id; } } $rtags=test(); foreach ($rtags as $tag) echo $tag->id." ";
Output for 5.5.24 - 5.5.30, 5.6.8 - 5.6.15
Parse error: syntax error, unexpected '$flipped' (T_VARIABLE), expecting '(' in /in/GqCGK on line 16
Process exited with code 255.

preferences:
157 ms | 1395 KiB | 22 Q