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] => [email protected] [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] => [email protected] [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
https://forums.phpfreaks.com/topic/240098-php-returning-looping-array-data/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.