Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Exploding a string with 3 parameters...
Old 04-07-2010, 02:06 AM Exploding a string with 3 parameters...
Isabella_Smith's Avatar
Ultra Talker

Posts: 285
Trades: 0
Hi,

I want to use explode function using 3 parameters.

For example this is the string:

Cellular Phone Repair & Services-Samsung

Now I want to break this string with space and the sign of '-' and '&' and space.....and the result should be:

array[0] = Cellular
array[1] = Phone
array[2] = Repair
array[3] = Services
array[4] = Samsung

Thanks for your help in advance!
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
buy all indian salwar Kameez, Sarees and clothes
Isabella_Smith is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-07-2010, 02:12 AM Re: Exploding a string with 3 parameters...
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Try preg_split:
http://us2.php.net/manual/en/function.preg-split.php

PHP Code:
$chunks preg_split('/[\s&-]+/''Cellular Phone Repair & Services-Samsung'); 
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 04-08-2010, 10:40 AM Re: Exploding a string with 3 parameters...
Average Talker

Posts: 22
Trades: 0
$str = "Cellular Phone Repair & Services-Samsung";
$ex = preg_split("@\s|&|-@",$str);
print_r($ex);
I too didn't find explode with multiple parameters like above.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
katierosy is offline
Reply With Quote
View Public Profile Visit katierosy's homepage!
 
Reply     « Reply to Exploding a string with 3 parameters...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.18655 seconds with 12 queries