Solved

string manipulation

Posted on 2013-01-30
1
214 Views
Last Modified: 2013-01-30
How do I cut the following string in order to get the file name (i.e. 24.swf)

/folNo1/playFlash.php?game=dGames/home/swf/24.swf
0
Comment
Question by:yaron89
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 2

Accepted Solution

by:
trevoC earned 500 total points
ID: 38837744
Here you go

string basename ( string $path [, string $suffix ] )

Open in new window


so basename takes a string that is a path and returns just the filename portion.

you could use the suffix portion of the above example to chop off the .swf part if you like or not use that option at all to return 24.swf

dirString = "folNo1/stuff/swf/24.swf";
fileNameOnlyString = basename(dirString);
//fileNameOnlyString contains 24.swf

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question