Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pull a sub string out of a variable?

Status
Not open for further replies.

james0816

Programmer
Jan 9, 2003
295
US
I can do this in regular programming code but since i'm not familiar with php, i need a little help.

I am passing a UNC file string value to another page. Looks like this: \\<server>\folder\folder\file

I would just like to strip the file portion off of this variable. The catch to this is that sometimes the length of the value can change. (I.e. \\<server>\folder\folder\folder\file) and the file name can be of any length too.

Any suggestions on how to do this?

thx
 
I can do this in regular programming code but since i'm not familiar with php
So PHP isn't regular programming code?


Explode the string on "\" into an array then take the last element.

Code:
<?php
$a = '\\a\b\c\d\e';

$b = explode('\\', $a);
print array_pop($b);
?>



Want the best answers? Ask the best questions! TANSTAAFL!
 
lol....not to me...i'm used to visual basic. web programming is a different language. or at least...what i've seen so far.

thx...that worked purty well.

 
Web programming isn't a language. It's a methodology. You can program web apps in c, C++, perl, python, PHP and a host of other languages.

PHP got it start as a web-specific language. But it has since then significantly grown.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top