End goal: Changing chunks of numbers in a database like 0000000 and 22222 and 333333333333 into different lengths. For example, phone numbers that may include prefixes like country codes (e.g. +00 (000) 000-0000, or a pattern of 2, 3, 3, 4), so the option of being able to change the length depending on a different phone number format would be nice.
I love the idea of using explode or chunk_split for the simplicity, as I will be processing a lot of data and I don't want it to drain the server too much:
$string = "1111111111";
$new_nums = chunk_split($string, 3, " ");
echo $new_nums;
^ Only problem here is that I can only use one digit for the length.
What's the best way to go about it? Should I create a function?