Search code examples
phpcakephp-2.0

Traversing Multi Dimensional Arrays


I am trying to get to the 'id' by looping through the multidimensional array '$ll10_violations'. How would I do that?

<?php echo $html->link('View Violation', '/violations/editllviolation/' . 
$ll10_violations[0]['Ll10Violation']['id']) ?>

Thanks,

CM


Solution

  • You just have to use a foreach loop:

    foreach($ll10_violations as $viloation){
        // Code here....
        // Access data like this $violation['key']
    }
    

    If you are not sure how, post your array structure and I'll help you out