Post value of array in cakephp

I have multiple check boxes on submiting form I want to post values from these check boxes

code for check box
<?php echo $this->Form->input(‘Project.chk[’.$device[‘id’].‘]’,array(‘multiple’ => ‘checkbox’,‘type’=>‘checkbox’,‘label’=>false,‘value’=> $device[‘id’])); ?>

when I print the whole form data by print_r($this->data);

output is

[Project] => Array

        [chk[2] =&gt; 2
        [chk[3] =&gt; 3
        [chk[4] =&gt; 4
        [chk[5] =&gt; 5
        [chk[215] =&gt; 215


Now I want just to show chk values how can i post values from chk . I have tried this one but its not working


Anybody know how to do?


Though I am not good with cakePHP, but seeing the array output, it looks that the ‘chk’ itself is an array you need to access it as follows:

echo $this->data['Project']['chk'][2]; // will print 2

//if you want to access all the values then loop the array:
foreach($this->data['Project']['chk'] as $userId){
    echo $userId . '<br />';

Thanks Raju Gautam

But its still giving the problem showing nothing…

I suspect the array output is correct as you supposed to be there. ‘[chk[2]’ this has been an index of an array element rather than the array.I don’t know how cakePHP parses form elements. So try something like this and see what it prints for you:

foreach($this->data['Project'] as $key=>$userId){
    echo $key . ' = ' . $userId . '<br />';