<?php $array = [ 'Some Text', 'Some Other Text (+£14.20)', 'Foo', 'Text Text (+£26.88)', 'Another One (+£68.04)', ]; $result = []; foreach ($array as $v) { sscanf($v, '%[^(](+£%f)', $item, $price); $result[rtrim($item)] = $price ?? 0; unset($price); } var_export($result);
You have javascript disabled. You will not be able to edit any code.