webdevask.com

Menu

  • Home
  • New
  • Add question

php - How to give space in sentence in string with preg_replace?

View Original

one text

Solution:

You can replace all chars other than lowercase letters with a space and the string:

$kamar = "12223233 sekamar berempat";
echo trim(preg_replace("/[^a-z]+/", " ", $kamar));
// => sekamar berempat

See the PHP demo.

Source

See also:

  • php สร้าง Google ชีตจากบัญชีบริการ

  • php - Laravel 8.0 Installation Failed

  • javascript - How to include HTML data (tags) as value in "arrayToDataTable" of Google Pie Chart?

  • how to Grouping array in php

  • php - vender folder from my laravel project has more 1k error

© 2021
E-mail: contact@webdevask.com
Back to top