str_replace : menghapus semua karakter spasi

syntax :
str_replace("string_expression1", "string_expression2", "string_expression3")

Contoh :

<?php
   $text = "Jakarta Adalah Ibukota Indonesia";
   $hasil = str_replace(" ","", $text);

   $rawstring = "Your replacement is a pleasure to have!";
   $malestr = str_replace("replacement", "son", $rawstring);

   echo "Sebelum = " . $text . "<br>";
   echo "Sesudah = " . $hasil . "<br><br>";

   echo "Sebelum : Son = " . $rawstring . "<br>";
   echo "Sesudah : Son = " . $malestr . "<br>";
?>

Output :

Sebelum = Jakarta Adalah Ibukota Indonesia
Sesudah = JakartaAdalahIbukotaIndonesia

Sebelum : Son = Your replacement is a pleasure to have!
Sesudah : Son = Your son is a pleasure to have!

0 Comments:

Post a Comment