Here's i have an issue : sentence : "12223233 sekamar berempat"
$kamar = $_POST['kamarpilihan'];
$kamarhuruf = preg_replace("/[^a-z]+""/", "", $kamar);
result: sekamarberempat
expectation: sekamar berempat
thank you
You can replace all chars other than lowercase letters with a space and trim
the string:
$kamar = "12223233 sekamar berempat";
echo trim(preg_replace("/[^a-z]+/", " ", $kamar));
// => sekamar berempat
See the PHP demo.
preg_replace("/[^a-z]+/", " ", $kamar)
?trim(preg_replace("/[^a-z]+/", " ", $kamar))
?