php - fastest way to get array block based on value contained within the block (not working) -


https://gist.github.com/jcranny/9465715

i have array (example)...

array (     [0] => array         (             [series] => stdclass object                 (                     [term_id] => 5                     [name] => moto2 2013                     [slug] => moto2-2013                     [term_group] => 0                     [term_taxonomy_id] => 3                 )              [race_number] => 77             [team] => technomah carxpert             [constructor] => suter             [machine] => honda cbr600rr         )     [1] => array         (             [series] => stdclass object                 (                     [term_id] => 6                     [name] => moto2 2014                     [slug] => moto2-2014                     [term_group] => 0                     [term_taxonomy_id] => 3                 )              [race_number] => 15             [team] => la fonte tascaracing             [constructor] => suter             [machine] => honda cbr600rr         )     [2] => array         (             [series] => stdclass object                 (                     [term_id] => 7                     [name] => moto2 2015                     [slug] => moto2-2015                     [term_group] => 0                     [term_taxonomy_id] => 3                 )              [race_number] => 15             [team] => mapfre aspar team moto2             [constructor] => suter             [machine] => honda cbr600rr         ) ) 

now able information each block.

for example echo data:

  • [race_number]
  • [team]
  • [constructor]
  • [machine]

but want echo data relevant specific [series]

i have [series] term_id key relevant data, i'm struggling node function work.


this function this:

function node_modify_riders_array($rider_id) {         $fields = get_field("rider_series_data", $rider_id);         foreach($fields $field_key => $field_val)         {             $new_fields[$field_val["series"]] = $field_val;         } return $new_fields;  } 


then how series specific data based on series term id.

$rider_series_data    = node_modify_riders_array($rider_id);     $series_id            = $series[0]->term_id;  $team            = $rider_series_data[$series_id]["team"]; $contstructor    = $rider_series_data[$series_id]["constructor"];    $machine         = $rider_series_data[$series_id]["machine"]; $race_number     = $rider_series_data[$series_id]["race_number"]; 


but thing wrong , can work out. can see i'm going wrong or me fix it.

massive in advance, appreciate help.


what problem is:

my function node_modify_riders_array returning null, causing $team, $contstructor, $machine, , $race_number not output anything.

if echo $series_id on example, 6

which should pass though node_modify_riders_array function , display relevant array values. it's not outputting , got no errors.

this full code can see trying do...

https://gist.github.com/jcranny/9465715

you using object array key , not term_id of series object.

function node_modify_riders_array($rider_id) {         $fields = get_field("rider_series_data", $rider_id);         foreach($fields $field_key => $field_val)         {             $new_fields[$field_val["series"]->term_id] = $field_val;                                           //^^^^^^^^^  <--- add         }         return $new_fields;  } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -