Convert array php to js array
public function convertToJsArray($name = null, $data){
if(is_null($name)){
$arrayJs = "var countriesReq = [ ";
}else{
$arrayJs = "var $name = [ ";
}
for($i = 0; $i < count($data); $i++){
if($i == count($data)-1){
$arrayJs .= "\"$data[$i]\"];";
}else{
$arrayJs .= "\"$data[$i]\",";
}
}
return $arrayJs;
}