smithmr8 Posted June 22, 2011 Share Posted June 22, 2011 I've got a selection of data helds in a number of arrrays. e.g. : Array ( [projects] => Array ( [project] => Array ( [0] => Array ( [id] => 316431 [name] => My Sample Project [iteration_length] => 1 [week_start_day] => Monday [point_scale] => 0,1,2,3 [account] => Luke [first_iteration_start_time] => 2011/06/06 07:00:00 UTC [current_iteration_number] => 3 [enable_tasks] => true [velocity_scheme] => Average of 3 iterations [current_velocity] => 8 [initial_velocity] => 10 [number_of_done_iterations_to_show] => 12 [labels] => admin,blog,cart,checkout,deployment,design,epic,featured products,ie6,needs discussion,orders,reporting,search,shopper accounts,shopping,signup / signin,usability,user generated content [allow_attachments] => true [public] => false [use_https] => false [bugs_and_chores_are_estimatable] => false [commit_mode] => false [memberships] => Array ( [membership] => Array ( [id] => 1002639 [person] => Array ( [email] => smithmr8@hotmail.co.uk [name] => Luke [initials] => LU ) [role] => Owner ) ) [integrations] => Array ( ) ) [1] => Array ( [id] => 316459 [name] => Testing [iteration_length] => 1 [week_start_day] => Monday [point_scale] => 0,1,2,3 [account] => Luke [first_iteration_start_time] => 2011/06/19 23:00:00 UTC [current_iteration_number] => 1 [enable_tasks] => true [velocity_scheme] => Average of 3 iterations [current_velocity] => 10 [initial_velocity] => 10 [number_of_done_iterations_to_show] => 12 [labels] => Array ( ) [last_activity_at] => 2011/06/22 10:23:31 UTC [allow_attachments] => true [public] => false [use_https] => false [bugs_and_chores_are_estimatable] => false [commit_mode] => false [memberships] => Array ( [membership] => Array ( [id] => 1002745 [person] => Array ( [email] => smithmr8@hotmail.co.uk [name] => Luke [initials] => LU ) [role] => Owner ) ) [integrations] => Array ( ) ) ) ) ) I need to be able to loop through the projects which are returned. I can get the data from each array manually, by doing (for example): To get the ID for the second project: $projects["projects"]["project"]["1"]["id"]; Is there any way I can loop through the projects, and list out the attributes of each project individually. ie. Display ID, name ect.. for #0 THEN Display ID, name ect.. for #1 And then continue if there are more than two projects.. Cheers. Quote Link to comment Share on other sites More sharing options...
TeNDoLLA Posted June 22, 2011 Share Posted June 22, 2011 Yes it is quite easy with loops. Could you please do and paste results.. echo '<pre>'; print_r($array); to make it more readable. I am to lazy to start figuring out your array structure from that helluva long string. Quote Link to comment Share on other sites More sharing options...
WebStyles Posted June 22, 2011 Share Posted June 22, 2011 you can use something like foreach($projects as $key=>$value){ ... } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.