[ create a new paste ] login | about

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

PHP, pasted on Jun 23:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
$refNumbers = array('C28', 'C29');
$partIds    = array('1AB010050093', '1AB008140029');

$combined = array();

foreach($refNumbers as $index => $refNumber) {
    if(!array_key_exists($index, $partIds)) {
        throw OutOfBoundsException();
    }

    $combined[] = array(
        'ref'  => $refNumber,
        'part' => $partIds[$index]
    );
}

print_r($combined);


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Array
(
    [0] => Array
        (
            [ref] => C28
            [part] => 1AB010050093
        )

    [1] => Array
        (
            [ref] => C29
            [part] => 1AB008140029
        )

)


Create a new paste based on this one


Comments: