Checkbox einträge durch komma trennen... Datenbank

DeeJay-Luke

Mitglied
Moin zusammen,

das script soll bewirken:
Formular mit checkboxen, jede gewählte zahl soll durch ein ", " getrennt sein das macht das script leider nicht

das ergebiss schaut so aus [ 1, 2 ,3, 4, ]

soll aber so ausehen [ 1, 2, 3, 4 ]

PHP:
		$theData = '';
		if(!empty($_POST["extra_box"]))
		{
    		foreach($_POST["extra_box"] as $theItem)
    			{
					$i++; 
				if($i < count($_POST["extra_box"])) 
            		$theData .= $theItem . ', ';
    			}
		}
 
Hi
Versuch mal damit:

PHP:
$theData = ''; 
        if(!empty($_POST["extra_box"])) 
        { 
            foreach($_POST["extra_box"] as $theItem) 
                { 
                    $i++; 
                    $theData .= $theItem;
                if($i < count($_POST["extra_box"])) 
                     $theData .= ', '; 
                } 
        }
 
Zurück