Got an issue with this guys, I somehow want to pass the $_POST parameter of the Checkboxes into a PHP function that then outputs a string with delimiters.

Here's my function that is included into the main page...

function Ash_ConvertArrayToDelimited($TheArrayToSplit, $TheDelimiter) {

foreach($TheArrayToSplit as $TheValue) {
	if (is_numeric($TheValue)) {
		$TheDelimitedString = $TheDelimitedString . htmlentities(trim($TheValue)) . $TheDelimiter;
	}
		return $TheDelimitedString;
}
}

And here's the line I'm running in the page itself (as the functions are an Included/Require_Once file)

$TheProfileLookingForID = Ash_ConvertArrayToDelimited($_POST['ProfileLookingForID'],'|');

For some reason, the resultant string only get the contents of the FIRST checkbox and one delimiter.

And to confirm, the checkbox's name DOES have the [] brackets so as to ensure that it collates an array.

Appreciate your help!

Any ideas?

    a simple example:

    <form action="" method="post">
    <input type="checkbox" name="boxes[]" value="1">1<br>
    <input type="checkbox" name="boxes[]" value="2">2<br>
    <input type="checkbox" name="boxes[]" value="3">3<br>
    <input type="checkbox" name="boxes[]" value="4">4<br>
    <input type="checkbox" name="boxes[]" value="5">5<br>
    <input type="submit" name="submit" value="submit">
    </form>
    
    <?php
    if (isset($_POST['submit']))
    {
        if (isset($_POST['boxes']))
        {
            echo 'you checked: ' . implode('|', $_POST['boxes']);
        }
        else
        {
            echo 'you did not check any boxes';
        }
    }
    ?>
    
      Write a Reply...