<?php $re = '/\d+(?= Sek)/'; $str = 'aaa ~120 Sek. 53 Sek. ~~ bbb asdfasf aasdf asdfasdf ~600 Sek. ~~ ccc ~60 Sek. 43 Sek. ~~ ddd ~240 Sek. 55 Sek. ~~'; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); // Print the entire match result #print_r($matches); $sum = 0; foreach ($matches as $item) { $sum += $item[0]; } echo $sum;
You have javascript disabled. You will not be able to edit any code.