farnoise Posted December 1, 2009 Share Posted December 1, 2009 Hi, I'm a newbie in PHP and I have a form that has about 130 check boxes (I know its a lot) these 130 boxes has been splited in different groups and each group has 20 boxes, SO some values are same in different groups. so what I want to do is use the same name for all check boxes but different values, I tries checkbox[] function but all it gives me in my message line is "Array" for ex. if I check 10 different boxes it should give the value names for 10 different boxes but all i see is "Array". PS: I dont want to echo my output, it has to be sent to recieptent via mail() function I got that all here is my code: check box name is = chkexpert[] for all check boxes HTML (only 3 of them is here) _____ <input name="chkexpert[]" type="checkbox" id="chkexpert" value="Voice mail" /> Voice mail <br /> <input name="chkexpert[]" type="checkbox" id="chkexpert" value="Long Dst. Code" /> Long Dst. Code <br /> <input name="chkexpert[]" type="checkbox" id="chkexpert" value="Laptop" /> Laptop <br /> ....... _______ PHP CODE $chkexpert = addslashes($_POST['chkexpert']); >>> in my message line I have; $message = " Hi, Your list is $chkexpert " So when visitor choose 4 of that check boxes I'm recieving email says : Hi, Your list is Array Thanks GUYS PLEASE HELP :'( :'( :'( Quote Link to comment Share on other sites More sharing options...
cags Posted December 2, 2009 Share Posted December 2, 2009 By naming the checkboxes with [] at the end you are turning them into arrays. When you echo an array you simply get the word 'Array' as you have already found. You will need to convert it into a string that contains all the values in the array. There's lots of ways of doing it, but here's a quick example of one way. function concat($a, $b) { if($a) { return $a . ", " . $b; } else { return $b; } } $input = array(1, 2, 3, 4, 5); $output = array_reduce($input, "concat"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.