-1

I have Two array both array have same key but I want same key in one array inside multiple value.

Input:

[coming_new_date] => Array
    (
        [0] => 2021-03-06
        [1] => 2021-03-07
        [2] => 2021-03-08
        [3] => 2021-03-09
    )

[coming_Day_name] => Array
    (
        [0] => Sat
        [1] => Sun
        [2] => Mon
        [3] => Tue
    )

Output:

array(

     [0] => array(
                    [0] =>2021-03-06
                    [1] =>Sat
                 )
     [1] => array(
                    [0] =>2021-03-07
                    [1] =>Sun
                 )
      [2] => array(
                       [0] =>2021-03-08
                       [1] =>Mon
                   )
)
Syscall
  • 19,327
  • 10
  • 37
  • 52
  • 1
    Does this answer your question? [Merging arrays with the same keys](https://stackoverflow.com/questions/5881443/merging-arrays-with-the-same-keys) – nice_dev Mar 05 '21 at 10:57
  • doesn't work!! they work like : Array ( [0] => 2021-03-06 [1] => 2021-03-07 [2] => 2021-03-08 [3] => 2021-03-09 [4] => Sat [5] => Sun [6] => Mon [7] => Tue ) – sagar jagade Mar 05 '21 at 11:05
  • You need to write a loop that does what you want. There are no built-in functions that can do what you require. – El_Vanja Mar 05 '21 at 11:21
  • @El_Vanja yes. how to do. i will try in loop also but not getting anwer – sagar jagade Mar 05 '21 at 11:27
  • 1
    If you've tried writing a loop, please edit the question, show your efforts and explain how the result differs from what you need. – El_Vanja Mar 05 '21 at 11:29

1 Answers1

0

try below code:

$output[][]='';

for($i=0; $i<4; $i++)
{
    $output[$i][0]=$coming_new_date[0];
    $output[$i][1]=$coming_day_name[0];
}
Farhan Ibn Wahid
  • 926
  • 1
  • 9
  • 22