remove whitespace from string php
snippet in php

remove spaces from string php

user1908

<?php
$phone = preg_replace( '/\s+/', '', "01234 567890" );
echo $phone;

remove empty spaces php

user988

$string = str_replace(' ', '', $string);

remove space from string php

user3868

<?php
$stripped = str_replace(' ', '', "10 1000 0000 000");
echo $stripped;

remove every whitespace php

user3501

$string = preg_replace('/\s+/', '', $string);

remove whitespace from string php

user9227

$str = "\n\n\nHello World!\n\n\n";
echo "With trim: " . trim($str);

php remove all whitespace from a string

user6877

//remove all white spaces from a string
$whatonearth=preg_replace('/\s/','',"what o n   ear th");