I am currently working with the following array,
Array
(
[0] => Array
(
[0] => Array
(
[candidate_id] => 41
[show_on_site] => urban talent
[first_name] => Barney
[surname] => Harwood
[gender] => male
[talent] => presenter
[skill] =>
[DOB] => 1983-11-30
[Location] => London
[contact_telephone] => 01234 567890
[contact_email] => [email protected]
[height] => 5' 1"
[eyes] => Brown
[hair_colour] => brown
[hair_length] => medium
[accents] => Native Northern, others include - Yorkshire, Liverpool, Manchester, Birmingham, Cockney, RP, Welsh, Scottish, German, American
[training] => n/a
[unions] => Member of the British Academy of Composers & Songwriters
Equity & MU Member
[visible] => yes
[availability] => yes
[availability_number] => 9999
[availability_order] => 0
[availability_comments] => BARNEY IS THE LATEST BLUE PETER PRESENTER AND CAN BE SEEN ON AIR MONDAYS & TUESDAYS AT 4.30PM ON BBC
[spotlight_url] =>
[youtube_showreel] =>
[date_created] => 2011-11-02 10:44:37
[created_by] => 1
)
)
[1] => Array
(
[0] => Array
(
[candidate_id] => 42
[show_on_site] => urban talent
[first_name] => Simon
[surname] => Ainley
[gender] => male
[talent] => actor
[skill] =>
[DOB] => 1987-06-12
[Location] => Huddersfield
[contact_telephone] => 01484 532751
[contact_email] => [email protected]
[height] => 5' 1"
[eyes] => blue
[hair_colour] => brown
[hair_length] => short
[accents] => Accents
[training] => Training
[unions] => Union Membership
[visible] => yes
[availability] => yes
[availability_number] => 9999
[availability_order] => 0
[availability_comments] => Availability Comments
[spotlight_url] => http://www.google.com
[youtube_showreel] => http://www.youtube.com/watch?v=sP4NMoJcFd4
[date_created] => 2011-11-08 11:28:12
[created_by] => 1
)
)
)
as you can see it is an array within an array type situation, I am trying to loop through it to pull out the first_name
+ surname
of each entry, however I get the following error when I try to do it,
A PHP Error was encountered
Severity: Notice
Message: Undefined index: firstname
Filename: admin/candidate_list.php
Line Number: 5
I looping through it like this at the moment,
<?php foreach ($candidates as $k => $v) : ?>
<li><a href="<?php echo site_url(); ?>candidates/card/id/<?php echo $v['id']; ?>"><?php echo $v[0]['first_name']. " ".$v[0]['surname']; ?></a></li>
What am i doing wrong?
$v['firstname']
and not$v['first_name']
. – Madara Uchiha Nov 15 '11 at 17:23$candidates
? – Francois Deschenes Nov 15 '11 at 17:24