Hapus ruang dari string php
<?php
$stripped = str_replace(' ', '', "10 1000 0000 000");
echo $stripped;
Unusual Unicorn
<?php
$stripped = str_replace(' ', '', "10 1000 0000 000");
echo $stripped;
$string = preg_replace('/\s+/', '', $string);
<?php
$phone = preg_replace( '/\s+/', '', "01234 567890" );
echo $phone;
$string = "this is my string"
$string = preg_replace('/\s+/', '', $string);
phpCopy<?php
$searchString = " ";
$replaceString = "";
$originalString = "This is a programming tutorial";
$outputString = preg_replace('/\s+/', '', $originalString);
echo("The original string is: $originalString \n");
echo("The string without spaces is: $outputString \n");
?>
$str = "\n\n\nHello World!\n\n\n";
echo "With trim: " . trim($str);