Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php insert hyphen into spaces in string

$test = "jjfnj 948";
$test = str_replace(" ", "", $test);  // strip all spaces from string
echo substr($test, 0, 3)."-".substr($test, 3);  // isolate first three chars, add hyphen, and concat all characters after the first three
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #insert #hyphen #spaces #string
ADD COMMENT
Topic
Name
5+9 =