Jump to content

PHP - Returning / Looping Array data


smithmr8

Recommended Posts

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.