just don't use array_values in foreach and should work -- Lep pozdrav, Tilen Majerle http://majerle.eu
2012/3/18 luftlinie <[email protected]> > hi everyone, > > i have an array "$book['BookAttachment']" like this: > ================== > > Array > ( > [0] => Array > ( > [title] => > [name] => booking.pdf > > ) > > [1] => Array > ( > [title] => > [name] => DSC_6576.JPG > > ) > > [2] => Array > ( > [title] => > [name] => tt.JPG > > ) > > ) > > > now i wanna go through that array and find a value that is defined in > a passed variable "$filename". once it found it i want to unset that > part of the array. but i cant get it to work.... this is my approach > > > foreach(array_values($book['BookAttachment']) as $key => $attachment) > { > if($attachment['name'] == $filename) > { > $arrayKeyToDelete = $key; > } > } > unset($book['BookAttachment'][$arrayKeyToDelete]); > > > the problem is "$key" wont point at the correct array index that is to > be unset. i think it returns the iteration number and not the index.. > > so how do i make sure that i delete the correct array, where filename > was found? > > i appreciate it. thank you!!!! > > kind regrads > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > [email protected] For more options, visit this group > at http://groups.google.com/group/cake-php > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
