0

I have the the next string:

String = "Name: James, Training, Physician, Hobbies: Sports, Reading, Age: 24".

With the following string to share with just the first ':' found, making the following:

stringsplit1 = "Name";
stringsplit2 = "James, Training, Physician, Hobbies: Sports, Reading, Age: 24";

or in the array. : S

2
  • 1
    where is your explode() ?
    – Raptor
    Commented Dec 8, 2014 at 4:21
  • you should be able to do this with the 3rd argument of explode() Commented Dec 8, 2014 at 4:22

1 Answer 1

1

explode()

explode(':',$string,2);
                    ^ ------------> limit [int]

Complete code:

$string = "Name: James, Training, Physician, Hobbies: Sports, Reading, Age: 24";
$ar = explode(":",$string,2);
print_r($ar);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.