Str_split string into 2 separate arrays

Hi,
I have the code below which works great. It takes a string and inserts <Play>digit from string.wav</Play>

$FromCaller = 1234567890;

$arr = str_split($FromCaller);
$new = '<Play>../audio/callin/' . implode('.wav</Play><Play>../audio/callin/', $arr) . '.wav</Play>';
echo $new;

Open in new window


Ideally what I"m after it to take the same string and create 2 arrays.
The first one being 3 digits long (the area code)
and the second the remaining 7 digits.

So a string like 1234567890

Would output looking like:
<Play>123.wav</Play>
<Play>4.wav</Play><Play>5.wav</Play> and so on...
LVL 1
tjyoungAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DerokorianCommented:
$number = '1234567890';

$areacode = substr($number,0,3);
$array = str_split(substr($number,3));

$new = '<Play>../audio/callin/' . $areacode .'.wav</Play><Play>../audio/callin/'. implode('.wav</Play><Play>../audio/callin/', $array) . '.wav</Play>';

echo $new;

Open in new window

0
Ray PaseurCommented:
You can use substr() to get the first three digits.
0
Ray PaseurCommented:
See if this makes sense...
http://www.laprbass.com/RAY_temp_tjyoung.php
<?php // RAY_temp_tjyoung.php
error_reporting(E_ALL);


$num = '1234567890';

// GET THE A/C AND NUMBER
$ac  = substr($num,0,3);
$nbr = substr($num, 3);

// PREPARE THE AC
$ac = '<play>' . $ac . '.wav' . '</play>';

// PREPARE THE NUMBER
$arr = str_split($nbr);
$new = '<play>' . implode('.wav</play><play>', $arr) . '.wav</play>';

// CONCATENATE THE STRINGS
$new = $ac . PHP_EOL . $new;
echo htmlentities($new);

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tjyoungAuthor Commented:
Both are perfect.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.