Jump to content

[SOLVED] Explode or Regex


karldesign

Recommended Posts

I don't know a way with explode, but with Regex and also with substr, it's a good way.

You can do the same with Regex like that:

<?php
   $num = '00001234567';
   preg_match('{([\d]{4})([\d]{3})([\d]{4})}', $num, $match);
   $new = $match[1].' '.$match[2].' '.$match[3];
   echo $new;
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.