I am trying to place a dash at certain intervals in a string in PHP. Here is the string I have, retrieved from a JSON GET:
fb396a80cada446f9e63d871116b8ddf
This is what I need the string to look like:
fb396a80-cada-446f-9e63-d871116b8ddf
How would I place the dashes at the intervals?
I've tried this, which didn't work:
$mcuuid = $json_decode->id;
$p1 = substr($mcuuid, 0, 7);
$p2 = substr($mcuuid, 8, 12);
$p3 = substr($mcuuid, 12, 15);
$p4 = substr($mcuuid, 16, 19);
$p5 = substr($mcuuid, 20, 31);
$final = $p1 . "-" . $p2 . "-" . $p3 . "-" . $p4 . "-" . $p5;