How do I split them?

Hi,
I have an array var which contains 6 values. I want to split this array var into two vars which each of the two holds three values. Example:

$x = array (
("1"."2"."3"."4","5","6");

And I want to split it into two vars like this:

$z = 123
$s = 456

Any help would be highly appreciated in advance
Hakeem
ShopiesAsked:
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.

PhatzerCommented:
Like this?

$z = $x[1] . $x[2] . $x[3];
$s = $x[4] . $x[5] . $x[6];
0
PhatzerCommented:
actually, it may start from 0 and not one, so:

$z = $x[0] . $x[1] . $x[2];
$s = $x[3] . $x[4] . $x[5];

That would result in:

$z = 123
$s = 456
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
Loganathan NatarajanLAMP DeveloperCommented:
i think you can use array_slice()  function to slice and make those variables,

<?php
$x = array (("1"."2"."3"."4","5","6");

$z = array_slice($input, 2);      
$s = array_slice($input, -2, 3);

?>

just try with this
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

ee_rleeCommented:
try this

$z = substr(implode(",", $array),1,strlen(implode(",", $array))/2);
$s = substr(implode(",", $array),strlen(implode(",", $array))/2+1);
0
ShopiesAuthor Commented:
This gave me the first,second,third...etc of the first word.
0
Loganathan NatarajanLAMP DeveloperCommented:
$x = array (("1"."2"."3"."4","5","6");

Is this structure correct??
0
PhatzerCommented:
Should be:
$x = array ("1"."2"."3"."4","5","6");

Surely?
0
Loganathan NatarajanLAMP DeveloperCommented:
i hope it might be,

$x = array ("1","2","3","4","5","6");

then everything works well.,
0
netmunkyCommented:
$x = array("1","2","3","4","5","6");

$z = implode("", array_slice($x,0,3));
$s = implode("", array_slice($x,3));
0
CWS (haripriya)Commented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
   Split: Phatzer {http:#20804600} & logudotcom {http:#20804614} & netmunky {http:#20805442}


Any objections should be posted here in the next 4 days. After that time, the question will be closed.

cyberwebservice
Experts Exchange Cleanup Volunteer
0
Computer101Commented:
Forced accept.

Computer101
EE Admin
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.