PHP String Cleanup Functions with Example

Today, We want to share with you PHP String Cleanup Functions with Example.In this post we will show you php remove all whitespace, hear for advanced php code examples we will give you demo and example for implement.In this post, we will learn about php remove all whitespace with an example.

PHP String Cleanup Functions with Example

There are the Following The simple About remove specific characters from string php Full Information With Example and source code.

As I will cover this Post with live Working example to develop ob_clean(): failed to delete buffer. no buffer to delete, so the prepared statement in php procedural is used for this example is following below.

Also Read This πŸ‘‰   How To Convert String Replace In Php Examples

PHP Clean Function

PHP cleanTextString Function

function cleanTextString($my_str_data) {
    //$my_str_data = preg_replace("/[^a-zA-Z0-9\s.,?()\'\"]/", "", $my_str_data);
    $my_str_data = preg_replace('/[^[:print:]]/', '', $my_str_data);
    return $my_str_data;

PHP cleanStringKey Function

function cleanStringKey($my_str_data) {
    $my_str_data = preg_replace('/[^a-zA-Z0-9_.]/', ' ', $my_str_data);
    $my_str_data = preg_replace('!\s+!', ' ', $my_str_data);
    return strtolower(str_replace(' ', '_', trim($my_str_data)));

PHP cleanNumber Function

function cleanNumber($my_str_data) {
    $my_str_data = preg_replace('/[^a-zA-Z_.]/', ' ', $my_str_data);
    $my_str_data = preg_replace('!\s+!', ' ', $my_str_data);
    return strtolower(str_replace(' ', '_', trim($my_str_data)));

PHP cleanEscapeString Function

function cleanEscapeString($my_str_data) {
    return addslashes(strip_tags($my_str_data));

PHP trim() Function

$data_string = "Welcome to Tamilrokers!";
echo $data_string . "<br>";
echo trim($data_string,"wel!");

PHP Filters Example

The PHP Filter Extension

<table border="2">
    <td>PHP Filter Name</td>
    <td>PHP Filter ID</td>
  foreach (filter_list() as $id =>$loveFilter) {
      echo '<tr><td>' . $loveFilter . '</td><td>' . filter_id($loveFilter) . '</td></tr>';

Web Programming Tutorials Example with Demo

Read :

Also Read This πŸ‘‰   Woocommerce get price in custom loop


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about how to give space in php code.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.