0

how to transform two arrays. could this be possible? to make arrays individually in php. how to transform two arrays. could this be possible? to make arrays individually in php.

Arrayone
(
    [0] => H00
    [1] => T00.0
    [2] => L00    
)
Arraytwo
(
    [0] => 1
    [1] => 2
    [2] => 3
)

Transform to like this

Array
(
    [icd] => H00
    [rank] => 1
)
Array
(
    [icd] => T00.0
    [rank] => 2
)
Array
(
    [icd] => L00
    [rank] => 3
)
georg
  • 211,518
  • 52
  • 313
  • 390
  • 2
    http://php.net/manual/en/function.array-map.php, example #4 – georg Mar 04 '15 at 11:39
  • 2
    possible duplicate of [Is there a php function like python's zip?](http://stackoverflow.com/questions/2815162/is-there-a-php-function-like-pythons-zip) – Artjom B. Mar 04 '15 at 11:40

2 Answers2

0

Assume you want to have an array containing all the transformed arrays inside.

$array1 = array('H00','T00.0','L00');
$array2 = array('1','2','3');

$result = array();
$array3 = array_combine($array2, $array1);

foreach($array3 as $key => $value)
    $result[] = array('icd' => $value, 'rank' => $key);

print_r($result);
sinaza
  • 820
  • 6
  • 19
-1

Try this..

You can able to combine two arrays in PHP.

$arr3 = array_combine($arr2, $arr1); print_r($arr3);

Sundar
  • 455
  • 1
  • 3
  • 13