<?php $str = "tea dae 15 abc 7,2 kg abc aa 1 aa"; $result = ""; if (preg_match('~(\d+(?:,\d+)?)\s*(kg)\b~', $str, $m)) { $result = $m[1] . $m[2]; } echo $result;
You have javascript disabled. You will not be able to edit any code.