I have a string
"1b00bd515bf8cbc5a86f3b714361fab6"
and I want to break it down like this:
"1b00bd51-5bf8cbc5-a86f3b71-4361fab6"
HOW DO I DO IT?
I have a string
"1b00bd515bf8cbc5a86f3b714361fab6"
and I want to break it down like this:
"1b00bd51-5bf8cbc5-a86f3b71-4361fab6"
HOW DO I DO IT?
Using the str_split()
function to create an array of your string separating every 8 characters and implode()
to join using a delimiter, try something like this:
$str = "1b00bd515bf8cbc5a86f3b714361fab6";
echo implode('-', str_split($str, 8));
Output:
1b00bd51-5bf8cbc5-a86f3b71-4361fab6
$str = "1b00bd515bf8cbc5a86f3b714361fab6";
print_r(preg_replace('/(\w{8})(?=\w)/', '$1-', $str));