slimboy007 Posted June 21, 2010 Share Posted June 21, 2010 how can i extract and add together the numeric values from the string $numbers $numbers = '{"val_a":7,"val_b":5,"val_c":4,"val_d":6,"val_e":5}'; Link to comment https://forums.phpfreaks.com/topic/205393-how-can-i-extract-and-add-the-numbers-from-a-string/ Share on other sites More sharing options...
trq Posted June 21, 2010 Share Posted June 21, 2010 Considering that string is serialized data. <?php $numbers = '{"val_a":7,"val_b":5,"val_c":4,"val_d":6,"val_e":5}'; $array = unserialize($numbers); echo array_sum($array); ?> Link to comment https://forums.phpfreaks.com/topic/205393-how-can-i-extract-and-add-the-numbers-from-a-string/#findComment-1074885 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.