在PHP中连接两个字符串数组

I have two string arrays.

Array Colors = { Blue, Green, Yellow, Red }

Array Toys = { Balloon, Whistle, Ball }

I want to concatenate these two arrays and display the output in such a way that, the result will look like this:

BlueBaloon
BlueWhistle
BlueBall
GreenBaloon
GreenWhistle
GreenBall
YellowBaloon
YellowWhistle
YellowBall
RedBaloon
RedWhistle
RedBall

Any help would be greatly appreciated. Thanks.

Just loop through both arrays. And push it into another one.

$newArray = array();

foreach($colors as $color) {
   foreach($toys as $toy) {
      $newArray[] = $color.$toy;
   }
}

Your syntax isn't php standard, however ....

$arrayColors = array('Blue', 'Green', 'Yellow', 'Red');
$arrayToys = array('Balloon', 'Whistle', 'Ball');

foreach($arrayColors as $color) {
 foreach($arrayToys as $toy) {
   echo $color.$toy.'<br/>';
 }
}

Untested:

//Loop through each color
foreach($Colors AS $color)
{
    //Now loop through each toy
    foreach($Toys AS $toy){
        //Now we can concatenate each toy with each color
        $toyColor = $color.$toy;
        echo $toyColor;
    }
 }

a simple foreach would do this for you.

$Colors =['Blue', 'Green', 'Yellow', 'Red'];

$Toys = ['Balloon', 'Whistle', 'Ball'];

foreach($color in $Colors){
    foreach($toy in $Toys){
       echo $color.$toy;
    }
}