Jump to content

[SOLVED] foreach list help needed


spfoonnewb

Recommended Posts

I have this function to list values from a form POST...

 

What it does right now is if there is only one posted it does not add the comma.

 

If there are more than one posted it adds the comma after each one..

 

What I want it to do is not add the comma on the LAST one.

 

<?php 

foreach ($_POST["eval"] as $eval) {
   		$arr[] = array($eval);
   	
}

foreach ($_POST["eval"] as $eval) {

$count = count($arr);

   		if ($count > 1) {
   			echo "$eval, ";
   		}
   		else {
   			echo "$eval";
   		}
}

?>

Link to comment
https://forums.phpfreaks.com/topic/44082-solved-foreach-list-help-needed/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.