Helping ordinary people create extraordinary websites!

Go Back   Web Development Forum > Website Programming > Server-Side Scripting
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-12-2005, 04:17 PM
Junior Member
 
Join Date: Dec 2005
Posts: 2
Cool PHP Explode

Hi;

ihve have a string "aaa_bbb_ccc_ddd.jpg and would like to product 2 varials that the first one will contain the file extension ( ie. jpg) and the second the contain "aaa bbb ccc ddd"

any advise is appreciaed
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 12-12-2005, 04:28 PM
Ducani's Avatar
Administrator
 
Join Date: Sep 2004
Posts: 224
Default

$v=explode("_",$string);
$e=explode(".",$string);

echo $e[1]; (for extension)
echo $v[0]; for aaa

Etc.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-12-2005, 05:35 PM
Junior Member
 
Join Date: Dec 2005
Posts: 2
Default

HI DUCATI;

for string "aaa_bbb_ccc_ddd.jpg"

$v=explode("_",$string);
$e=explode(".",$string);
echo $e[1]; (for extension)
echo $v[0]; for aaa

the $e=explode(".",$string); for good .

but the echo $v[0]; dispalys only aaa

any advise ?
thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 12-13-2005, 08:42 AM
Ducani's Avatar
Administrator
 
Join Date: Sep 2004
Posts: 224
Default

use

echo ereg_replace(".jpg","",$v[$i])

where $i= the values that you are looping through

in your loop and that whould work fine.

Last edited by Ducani : 12-13-2005 at 08:48 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 10-05-2006, 06:00 AM
Junior Member
 
Join Date: Oct 2006
Posts: 1
Default

Hi, This post is very informative, however I would like some specific information. If someone can help me then please send me a private message. Best Regards,
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 01-13-2008, 11:53 AM
BigAlReturns's Avatar
Moderator Extraordinaire!
 
Join Date: Dec 2007
Location: The Wirral, England
Posts: 291
Send a message via MSN to BigAlReturns
Default

There's no need in this case to explode using _ , we can just use the . as our explode symbol, as long as the filename (aaa_bbb part) is never going to contain a .

$parts=explode(".",$string)

The two variables are then $parts[0] - contains aaa_bbb etc
and $parts[1] - contains .jpg
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Thread Tools
Display Modes

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Navagation Problems PLEASE HELP pootytang69 Server-Side Scripting 2 12-11-2007 12:37 AM
Best php script site? reach2seo Server-Side Scripting 6 12-10-2007 01:32 PM
How to browse php nguyen van viet Server-Side Scripting 3 10-23-2007 05:03 AM
problem with mysql and php dharshini Server-Side Scripting 1 07-25-2007 02:43 AM
Need PHP website help! Good Guy Server-Side Scripting 0 02-15-2006 08:21 PM


All times are GMT -5. The time now is 03:13 AM.


Website Design by Ducani Media Group
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.