[ create a new paste ] login | about

Link: http://codepad.org/Lq8iw29w    [ raw code | output | fork ]

PHP, pasted on Oct 14:
<?php
$items = Array
    (
       0 => 'Title 1',
       1 => 'Image 1.jpg',
       2 => 'Title 2',
       3 => 'Image 2.png',
       4 => 'Text 1',
    );
    $order = Array
    (
       0 => 1,
       1 => 4,
       2 => 0,
       3 => 2,
       4 => 3,
    );
    
    foreach ($order as $itemPosition) {
        $sorted[] = $items[ $itemPosition ];
    }
    
    // optionally 
    ksort($sorted);
    var_dump($sorted);


Output:
1
2
3
4
5
6
7
8
9
10
11
12
array(5) {
  [0]=>
  string(11) "Image 1.jpg"
  [1]=>
  string(6) "Text 1"
  [2]=>
  string(7) "Title 1"
  [3]=>
  string(7) "Title 2"
  [4]=>
  string(11) "Image 2.png"
}


Create a new paste based on this one


Comments: