I am a student with PHP and I have a question from this course I am taking which I am able to produce my own solution which works, however the course uses some sort of "fill in the blank" testing method on their web page which means parts of the code cannot be edited.
Basically I have this right now:
<?php
$myArray = array(2,4,6,8);
foreach($myArray as $value)
echo "Points are $value\n";
?>
But it prints "Points are 2 Points are 4 Points are 6 Points are 8"... It needs to print Points are 2 4 6 8 (so print a value with each loop with a space). I know that there is a method that measures the number of arrays against what is being printed before it stops, however I haven't been able to figure it out.
EDIT: Here is the actual question from the webpage of my school's course:
<?php
$numberstring = $_GET['numberstring'];
$numberarray = explode(',',$numberstring);
//your code here
echo "Points are $value\n";
?>
echo "Points are 2 4 6 8";:)$value = str_replace(","," ",$numberstring), ignoring the array entirely) or as already pointed out, use implode() ($value = implode(" ", $numberarray)) or more convoluted possibilities. You can also use a foreach to concatenate as a string if that's the requirement ($value;foreach($numberarray as $number){$value .= $number." ";}) --- you have to pick the way that answers the question since we can't see it.