Home / Snippets / How to Trim   with PHP
How to Trim   with PHP cover

How to Trim   with PHP

1K

3 years ago

0 comments

In this short snippet you will learn how to trim   using trim() function. To do that you can simply use the trim and the pass in the string to trim as the 1st parameter and 2nd parameter the special character to trim. In this case, it would be "chr(0xC2).chr(0xA0)". For the code implementation do refer to the code example below.
<?php

$key = ' '; // imagine the content of this $key is &nbsp;

$newKey = trim($key, chr(0xC2).chr(0xA0));

if ($newKey === '') {
    echo 'it\'s empty';
}

Other Reads

notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this