Awptics Posted December 3, 2007 Share Posted December 3, 2007 I'm taking a PhP class and I was given a project to make an array with the statistics for the whole roster of the Chicago Bears. I am then supposed to add up all the weights and find the average, then convert the heights to numeric inches and and find the average then convert it back into 6'4'' format, then find the average age of the team, so its all pretty much the same thing, I need to find a way to pull the information out of the array and mess with it, this is what i have so far, how do i pull this information out of the array so i can manipulate it. <?php $characters=array( array( "number"=>95, "Fname"=>"Anthony", "Lname"=>"Adams", "Position"=>"NT", "Height"=>"6'0''", "Weight"=>"300", "Birthdate"=>"6/18/1980", "College"=>"Penn_State", ), array( "number"=>97, "Fname"=>"Mark", "Lname"=>"Anderson", "Position"=>"DE", "Height"=>"6'4''", "Weight"=>"255", "Birthdate"=>"5/26/1983", "College"=>"Alabama", ), Quote Link to comment https://forums.phpfreaks.com/topic/80023-array-question/ Share on other sites More sharing options...
toplay Posted December 3, 2007 Share Posted December 3, 2007 You can use "for" loops or "foreach". <?php // Loop through array for ($i = 0, $intCnt = count($characters); $i < $intCnt; $i++) { echo $characters[$i]['Weight']; // Would list weight as an example } ?> Quote Link to comment https://forums.phpfreaks.com/topic/80023-array-question/#findComment-405501 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.