0

I am building a table in which i should put some values inside the <td></td>.

What I have is a $checked value which I convert it in some string like: id1,id2,id3

What I need to do is a loop which permits me to print this values like this. Something like this:

(for i=0, i<length of words, i++) {
echo "<td> .id[i].</td>"
}

My real variable is this:

 if(isset($_POST['Submit'])) {
    echo "<pre>";
    $checked = implode(',', $_POST['checkbox']);
    echo $checked;

Thanks!

1
  • What are you having trouble with? Commented Jun 22, 2012 at 16:11

1 Answer 1

1

If $_POST['checkbox'] is already an array then you don't have to implode() it before processing :

foreach ($_POST['checkbox'] as $id) {
    echo '<td>' . $id . '</td>';
}
Sign up to request clarification or add additional context in comments.

3 Comments

Yes, in fact it was stupid from my part to post this question, i already found a solution :) thanks!
Note that this will fail and issue a warning if $_POST['checkbox'] is not an array (very possible).
One question please, i see better now, i need to print only the checkbox values, but how can i limit it to print me just 4 values, i mean if the checkbox is an array and has 4 values, it should print me 4..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.