I get these numbers seperated by commas from a textarea but I get an error when I try to loop through them. How do I do it? This is my code:
$numbers = $_GET['numbers'];
foreach($numbers as $number){
echo $number;
}
You should first make an array out of $numbers. You can do this by adding this line:
$numbers = explode(',', $_GET['numbers']);
Then, before you use them in the foreach loop you should use trim() to remove whitespace from the start and end:
foreach($numbers as $number){
$number = trim($number);
echo $number
}
$_GET['numbers']is an array? Apparently it is not. Dovar_dump($_GET['numbers'])and see.