I have an array of arrays that contain array key with the value, here the example :
Array (
[0] => Array ( [Hotel] => N [Jayakarta] => NE [Jaya] => NE [sangat] => ADV [nyaman] => ADJ [ditempati] => V. )
[1] => Array ( [Andi] => NOB [Hotel] => N [menginap] => V [disana] => N [selama] => N [satu] => NUM [minggu] => N. )
)
I want to make an output if I found a key of "Hotel" then I will print next key from "Hotel". For example :
Hotel Jayakarta Jaya
Hotel menginap disana
Here's what I am doing for the moment:
foreach($token2 as $index => $tok){
foreach ($tok as $tokkey => $tokvalue) {
if ($tokkey == "Hotel" and $tokvalue == "N"){
echo $tokkey . " " ;
while($cek == true && $x <= 2){
$next = next($tok);
echo key($tok). " " ;
$x++;
}
echo ", ";
$x = 1;
}
}
}
And the output :
Hotel Jayakarta jaya sangat , Hotel Hotel menginap
The Expected Output should be as below:
Hotel Jayakarta jaya sangat , Hotel menginap disana selama
Any help is much appreciated, Thank you.