I have a situation where I am trying to take the values out of a form multiple select and send them off as a concatenated string rather that as an array. The values for the multi select box would be like this:
- 11111
- 222222
- 333333
I would like the values to have a leading zero if under 6 chars (012345) which is done below: (these are two different variations)
foreach ($_POST["book"] as $books)
{
$book = $book.str_pad($books, 0, 6, " ", STR_PAD_LEFT);
}
foreach ($_POST["book"] as $books)
{
$book .= str_pad(substr($books, 0), 6, " ", STR_PAD_LEFT);
}
My goal is to have these concat together as a string like:
- 011111222222333333
I am not sure what I am doing wrong here but I keep getting the PHP error "Invalid argument supplied for foreach()"
Any guidance is highly appreciated. I have been searching for some answers with no luck.
<select multiple name="book" id="book" size="3">
<option value="11111" selected="selected">11111</option>
<option value="222222">222222</option>
<option value="333333">333333</option>
</select>
$book = '';
$param[] = $bookList->getToolkitService()->AddParameterChar('both', 2500, 'book', 'book', $book);
Not sure if this is adequate information but the total string being sent off would be 2500 chars