Php Insert Hyphen Into Spaces In String

[Solved] Php Insert Hyphen Into Spaces In String | Php - Code Explorer | yomemimo.com
Question : php insert hyphen into spaces in string

Answered by : annoyed-alpaca-lxbc75g55bca

$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 : https://stackoverflow.com/questions/48857567/php-make-spaces-in-a-word-with-a-dash | Last Update : Sat, 24 Oct 20

Answers related to php insert hyphen into spaces in string

Code Explorer Popular Question For Php