1
I have these 2 arrays:
$musica = [
["file" => "musica1"],
["file" => "musica2"],
["file" => "musica3"],
["file" => "musica4"],
];
$aviso = [
["file" => "aviso1"],
["file" => "aviso2"],
];
I’m trying to make a loop where every 1 song it adds 1 warning...
$resultado = array();
foreach ($musica as $mIndex => $mValue) {
$resultado[] = $mValue;
foreach ($aviso as $aValue) {
if ($mIndex % 1 == 0) {
$resultado[] = $aValue;
}
}
}
echo json_encode($resultado);
This way it returns the following result:
musica1
aviso1
aviso2
musica2
aviso1
aviso2
musica3
aviso1
aviso2
musica4
aviso1
aviso2
I wish it were so:
musica1
aviso1
musica2
aviso2
musica3
aviso1
musica4
aviso2
if ($mIndex % 1 == 0)
, there is some number that is not divisible by 1?– Woss