Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

PREVIOUS NEXT
Code Example
Php :: invalid datetime format 1292 
Php :: php number to color 
Php :: laravel log to console 
Php :: laravel remove duplicates from array 
Php :: php random string 
Php :: php turney if 
Php :: laravel seed 
Php :: add shortcode in short description 
Php :: how to recover xampp deleted files 
Php :: get template part wordpress 
Php :: run a server php terminal 
Php :: time to string in php 
Php :: where not null in laravel 
Php :: how to use wherein in json array laravel 
Php :: laravel dump query 
Php :: count remaining days php 
Php :: laravel new date 
Php :: get extension from filename php 
Php :: php search the key off bigger value 
Php :: sum of columns laravel eloquent 
Php :: How to validate a file type in laravel 
Php :: routing code in drupal 8 
Php :: wordpress post revisions config 
Php :: laravel multiple where conditions 
Php :: updating-product stock quantity programmatically woocommerce 
Php :: laravel image ratio validation 
Php :: lcomposer symfony/filesystem 
Php :: how to start laravel project 
Php :: reset password multipple database laravel 
Php :: php fix array keys 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =