Home » PHP String Cleanup Functions with Example

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.

Read Also:  Soft Delete Cascade using Laravel Eloquent Example

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.

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 :

Read Also:  Encrypt and Decrypt files using PHP


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 infinityknow.com 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.

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Auto Post on Facebook Page using Facebook PHP API
  2. Read Also:  Laravel Free charts and graphs for HTML5, JQuery and Javascript
  3. Read Also:  Enable Disable settings jQuery DataTables
  4. Read Also:  remove special characters from string php
  5. Read Also:  Create Order and Invoice using Magento
  6. Read Also:  Ajax Jquery Column Sorting Results using PHP MySQL
  7. Read Also:  Laravel Email Verification Script Example
  8. Read Also:  Remove Special characters from String php
  9. Read Also:  Laravel 6 Get Config Variable Example - PHP
  10. Read Also:  SQL SELECT SUM on multiple INNER JOIN with another table

Leave a Comment

Your email address will not be published. Required fields are marked *