按值排序数组

I have this post array

Array ( 
[imgurl_3] => http://localhost/wordpress/wp-content/uploads/2014/03/05-239x300.jpg
[imgtekst_3] => Write a text for the slide 
[imgurl_4] => http://localhost/wordpress/wp-content/uploads/2014/03/img_2184-300x225.jpg
[imgtekst_4] => Write a text for the slide 
[update_gallery] => Save changes )

The numbers in the end of the imgurl and imgtekst are dynamic. So. I want to pair the imgurl_3 & imgtekst_3, and so on. To update into a database.

Any smart PHP functions for this?

Thanks

    $array = [
        'imgurl_3' => 'http://localhost/wordpress/wp-content/uploads/2014/03/05-239x300.jpg',
        'imgtekst_3' => 'Write a text for the slide',
        'imgurl_4' => 'http://localhost/wordpress/wp-content/uploads/2014/03/img_2184-300x225.jpg',
        'imgtekst_4' => 'Write a text for the slide',
        'update_gallery' => 'Save changes'
    ];
    $output = [];
    foreach ($array as $key => $item) {
        $intKey = filter_var($key, FILTER_SANITIZE_NUMBER_INT);
        if ($intKey) {
            $key = preg_replace('/_\d/', '', $key);
            $output[$intKey][$key] = $item;
        }
    }
    print_r($output);

You could use a for loop and select correlated entries:

for($i = 0; $i < $whatever; $i++) {

   if(array_key_exists('imgurl_' . $i, $array)) {
      $value = $array['imgurl_' . $i];
      $value2 = $array['imgtekst_' . $i];
   }

   $sqlQuery = '<UPDATE using $value and $value2>';
}