[ create a new paste ] login | about

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

PHP, pasted on Sep 7:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php

$names = array('John', 'Alice', 'Tom');
$cities = array('London', 'NY', 'Boston');
$years = array('1999', '2010', '2012');
$colors = array('red', 'blue', 'green'); 

$newArray = array();

foreach($names as $num => $name){
    $newArray[] = $name." ".$cities[$num]." ".$years[$num]." ".$colors[$num];
}

var_export($newArray);


Output:
1
2
3
4
5
array (
  0 => 'John London 1999 red',
  1 => 'Alice NY 2010 blue',
  2 => 'Tom Boston 2012 green',
)


Create a new paste based on this one


Comments: