php : Menghilangkan spasi dan whitespace dengan php

Oleh : Abah Razi

بسم الله الرحمن الرحيم

Untuk hanya menghilangkan spasi, gunakan str_replace:

[code language=”php”]

$string = str_replace(‘ ‘, ”, $string);

[/code]

Untuk menghilangkan seluruh whitespace, gunakan preg_replace:

[code language=”php”]

$string = preg_replace(‘/\s+/’, ”, $string);

[/code]

About Reza Ervani 425 Articles
Adalah pendiri programming.rezaervani.com -

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.