Replace all the space in a string with underscore - Php

Replace all spaces

Snippet Code


  
Rate this page :
  [ 0 votes]

The str_replace function replaces all the occurences of the first argument with the second argument. We need to just give an empty space as the first argument in this case.

$str1="hello world"; $str1=str_replace(" ","_",$str1);

Tags


Ask Questions

Ask Question