3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $post = array( "name" => "John", "user" => "1" , "title" => "hello" , "uploader_0_name" => "pic.jpg", "uploader_0_status" => "done", "uploader_1_name" => "aaaa.jpg", "uploader_1_status" => "done", "uploader_2_name" => "Tulips.jpg", "uploader_2_status" => "failed", "uploader_count" => "3" ); foreach ($post as $key => $value) { if (preg_match('/^[a-z]+_(\d)_([a-z]+)$/', $key, $matches)) { $result[$matches[1]][$matches[2]] = $value; } } print_r($result);
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [0] => Array ( [name] => pic.jpg [status] => done ) [1] => Array ( [name] => aaaa.jpg [status] => done ) [2] => Array ( [name] => Tulips.jpg [status] => failed ) )