php foreach getting values from an array

Posted by sea_1987 on Stack Overflow See other posts from Stack Overflow or by sea_1987
Published on 2010-04-22T15:04:20Z Indexed on 2010/04/22 15:13 UTC
Read the original article Hit count: 237

I am having trouble accessing the values in an array, the array looks like this,

Array
(
    [0] => Array
        (
            [id] => 1661
            [code] => 849651318
            [job_status] => 4
            [looking_for] => Lorem ipsum
            [keywords_education] => Derby University
            [sector_id_csv] => 10,21,9,22,26
            [last_job_title_1] => Programmer
            [last_job_employer_1] => HBOS
            [city] => Bury
            [expected_salary_level] => LEVEL_2
            [education_level] => COLLEGE
            [job_looking_for] => 
            [is_contract] => Y
            [is_permanent] => N
            [is_temporary] => Y
        )

)
Array
(
    [0] => Array
        (
            [id] => 402
            [code] => 849650059
            [job_status] => 3
            [looking_for] => Lorem ipsum
            [keywords_education] => Paris College
            [sector_id_csv] => 27,22,19,21,12
            [last_job_title_1] => Programmer
            [last_job_employer_1] => HSBC
            [city] => Bury
            [expected_salary_level] => LEVEL_2
            [education_level] => COLLEGE
            [job_looking_for] => 
            [is_contract] => N
            [is_permanent] => Y
            [is_temporary] => Y
        )

)
Array
(
    [0] => Array
        (
            [id] => 1653
            [code] => 849651310
            [job_status] => 3
            [looking_for] => Lorem ipsum
            [keywords_education] => Crewe University
            [sector_id_csv] => 27,15,19,21,24
            [last_job_title_1] => Programmer
            [last_job_employer_1] => ICI
            [city] => Bury
            [expected_salary_level] => LEVEL_2
            [education_level] => UNIVERSITY
            [job_looking_for] => 
            [is_contract] => N
            [is_permanent] => Y
            [is_temporary] => Y
        )

)

I am trying to get the values out, I have tried doing the following,

foreach ($result as $rslt) {
    echo $rslt->id;
}

I have also tried,

foreach ($result as $rslt) {
    $rslt['id'];
}

But none of this works, I dont know why, can anyone help?

© Stack Overflow or respective owner

Related posts about php

Related posts about loops