I have two arrays of indefinite length arr1
and arr2
. Want to assemble a new array res
I have two arrays of indefinite length arr1
and arr2
. Want to assemble a new array res
not very good at php. It should be universal in js.
var arr1 = [1,2,3];
var arr2 = ['a','b','c','d'];
var arr = [];
arr1.forEach(i=>{
arr2.forEach(j=>{
arr.push([i,j]);
})
})
console.log(arr)
$a = [1,2,3];
$b = ['a','b','c','d'];
$res = [];
for($i = 0; $i < count($a); $iPP)
{
for($j = 0; $j < count($b); $jPP)
{
$res[] = [$a[$i],$b[$j]];
}
}
var_dump($res);
Previous: Js uses the array reorganization method to return the course name and the number of courses
default value 2018 04 16, 2018 04 17, 2018 04 18, 2018 04 19, 2018 04 20, 2018 04 21, 2018 04 28 when I deal with it on the other side how to convert it to array and send json to the specified http? Using curl $data = array( "date" =&g...
$courseDetail = M( course ) ->field( c.course_id,c.name,from_unixtime(c.time) as course_time,c.room_id,tu.teacher_id,tu.relname as teacher_name, tu.mobile as teacher_mobile,su.student_id,su.nickname as student_name,su.mobile as student_...
$data(0=>array( city => , addressid =>1, ordersn => 456786a , goods => ), 1=>array( city => , addressid =>1, ...
<?foreach ($restaurant_get_all->restaurants as $key) {?> <?foreach ($region_get_all->regions as $key2) {?> <option value="<?=@$key2->{ region-name };?>"><?=@$key2->{ region-name };...
how do I use a function to cross merge two arrays? ...
I d like to check the data structure how can I get the data after the second round? complete structure: I can get the "chinese-name " of "restaurants-involved " this way foreach ($order_get_one->{ restaurants-involved } as $key){ echo $k...
this problem has been bothering me not to be able to Rest for several days! How to reassemble it into a new format? the content is written at will. Mainly the format! The number after sitePerEpisode is the number of sets : $ceshi= $$1$http: v.you...
such as when querying BTC. Take out the BTC data inside. when querying ETH. Just withdraw all the data in the ETH. { "data": { "1": { "id": 1, "name": "Bitcoin", ...
because every user will have one or more attribute structures like this: so if I do this <? foreach ($data->{ attributes } as $value) { echo $value; }?> can list every id now the problem is that this array has several different c...
$arr = [1,2,3]; var_dump($arr); syntax error, unexpected [ ; tp;...
problem description php two-dimensional array is divided into a new array based on the addition of price values and those greater than 20 related codes Please paste the code text below (do not replace the code with pictures) Array () [0] =&g...
problem description $data=array ( 1 => 8 , 2 => 56 , 3 => 64 , 4 => 90 , 5 => 11 , 6 => 32 , 7 => 30 , 8 => 90 , ) how to get the key value of $data is 11, put all the previous key values...