Create a script that displays 1-2-3-4-5-6-7-8-9-10 on one line. There will be no hyphen(-) at starting and ending position
<?php for($x=1; $x<=10; $x++) { if($x< 10) { echo "$x-"; } else { echo "$x"."\n"; } } ?>
Sample Output:
1-2-3-4-5-6-7-8-9-10
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer