I just tried to create a spinner using MySQL and PHP, but after a few a hours it displays "ArrayArrayArray" in front of the expected output.
if($_POST['artikel']){
$artikel = nl2br($_POST['artikel']);
$ar = explode("\n\r",$artikel);
$hasil = "";
foreach($ar as $ars){
$newstring1 = explode(" ", $ars);
foreach($newstring1 as $newstring2){
$newstring3 = explode("\n", $newstring2);
foreach($newstring3 as $newstring4){
$newstring5 = explode(",", $newstring4);
foreach($newstring5 as $value){
$cari = mysql_query("select * from sinonim where kata1='$value'");
$j = mysql_num_rows($cari);
if($j>0){
$ka = mysql_fetch_array($cari);
$hasil = $hasil."<span class='re'>".$ka['kata2']." ";
$hasil = explode(",", $hasil);
foreach($hasil as $vv) {
$hasil = $hasil.$vv."</span> ";
}
}else{
$cari2 = mysql_query("select * from sinonim where kata2='$value'");
$j2 = mysql_num_rows($cari2);
if($j2>0){
$ka2 = mysql_fetch_array($cari2);
$hasil = $hasil."<span class='re'>".stripslashes($ka2['kata1'])."</span> ";
}else{
$hasil = $hasil.$value." ";
}
}
}
}
}
}
echo $hasil;
}
The result looks like this
ArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayhello all......
Why is "Array" printed? How can I avoid that?