I tested this code in WAMP server
<?php
$conn = mysql_connect ("localhost", "root","") or die (mysql_error());
mysql_set_charset('utf8',$conn);
mysql_select_db ("movedb");
$values = new Array();
$i = 0;
$text = $_POST['jam'];
$arrayText = explode(" ", $text);
foreach($arrayText as $val) {
$query = mysql_query("SELECT * FROM WORD WHERE ENGLISH = '$val'");
while($r = mysql_fetch_array($query)) {
$values[$s] = $r['SINHALA'];
$i++;
}
}
foreach($values as $val) {
echo $val.' ';
}
?>
but showing this error
Parse error: syntax error, unexpected 'Array' (T_ARRAY)
use just this
$values = array();
$values[$s] = $r['SINHALA'];
this should be
$values[$i] = $r['SINHALA'];
and
$values = [];
$s is neither initialized nor incremented, its not being used. You need correction on $s. Make it $i.
Change :
$values[$s] = $r['SINHALA'];
to
$values[$i] = $r['SINHALA'];