Skip to main content

Posts

Showing posts with the label multidimensional-array

Remove the parent array key in PHP?

I have an array structure like this : Array ( [donate] => Array ( [amount_other] => 222 [pay_method] => Array ( [5] => Array ( [first_name] => sam [last_name] => indi [cc_type] => mc [cc_number] => 5123456789012346 [cc_ccv2] => 111 [cc_exp_month] => 10 [cc_exp_year] => 20 ) ) [notes] => Test comment. ) ) I want to remove key [5] from the array, so that the new array becomes : Array ( [donate] => Array ( [amount_other] => 222 [pay_method] => Array ( [first_name] => sam [last_name] => indi [cc_type] => mc [cc_number] => 5123456789012346

Multi-Dimensional array count in PHP

I have a multi-dimentional array set up as follows array() { ["type1"] => array() { ["ticket1"] => array(9) { // ticket details here } ["ticket2"] => array(10) { // ticket details here } ["ticket3"] => array(9) { // ticket details here } } ["type2"] => array() { ["ticket1"] => array(9) { // ticket details here } ["ticket2"] => array(10) { // ticket details here } ["ticket3"] => array(9) { // ticket details here } } } etc. I am trying to get a count of the total number of tickets in the array (number of second level items), but the number of types is variable as are the number of fields that each ticket has, so I cannot use COUNT_RECURSIVE and maths