PHP variable with multiple strings to an array -
this code in drupal view table template $row = content get..
var_dump($row); // output: array(5) { ["field_datum"]=> string(0) "" ["field_werf"]=> string(9) "comis cui" ["field_machine"]=> string(17) "graafmachien d293" ["field_aantal_uren"]=> string(1) "5" ["view_node"]=> string(50) "bekijk" } $uren = $row['field_aantal_uren']; var_dump($uren); // output: string(1) "5" string(1) "7" string(1) "1"
i've tried explode, str_replace, preg_replace 3 strings in array can loop on them them , make sum. can't make work..
any suggestions transform variable array?
you var_dump
ing within loop. try this:
$uren[] = $row['field_aantal_uren'];
and outside of loop, have array.
echo array_sum($uren);