Hi I have a simple question regarding the array.
I am trying to use foreach loop to echo the vars. However, there are times that the variable wont' be an array
I have created a if statement to check the variable type, but I am not sure if it's the best practice doing it.
Are there any better way to do what I need? Thanks a lot!
My codes
$test = $_GET['testVar'];
if(is_array($test)){
foreach($test as $t){
echo $t;
}
}else{
echo $test;
}