mga master naa koy question gamay
help in getting the string after the slash in php?
ex.
folder/filie.txt
i want to get the string "file.txt"
$vhar=file.txt;
thank you
mga master naa koy question gamay
help in getting the string after the slash in php?
ex.
folder/filie.txt
i want to get the string "file.txt"
$vhar=file.txt;
thank you
Maybe this will help:
Regular-Expressions.info - Regex Tutorial, Examples and Reference - Regexp Patterns
e explode na oi..
$path = "folder/filie.txt";
$string = explode("/",$path);
array ang result ane.. e echo ang $string[1];
naay simple kaayo ay
http://php.net/manual/en/function.basename.php
$filepath="folders/file.txt";
$tmp=explode('/',$filepath);
$fname= $tmp[count($tmp)-1];
I hope this helps
yep. ni-post ra ko kay wa man jud naka-post about sa basename, basin makatabang pa diay ug lain. kung regular expressions gamiton mao ni akong ika-share...
about sa uban posts nga explode ang gigamit, akong ika-suggest kay same sa post ni sanggano_boy. i-explode, then count, then kuhaon ang pinaka-last nga item sa array.PHP Code:
$path = "/home/darkhero/file.txt";
$file = (preg_match("/\/?([^\/]+)$/", $path, $file)) ? $file[1] : false;
echo $file;
EDIT: another reason nga ni-post ko kay naay flaws ang previous posts before sa akoa. kung way slash, mo-fail ang post ni bishop_; kung more than one slash, mo-fail ang post ni romano2717.
EDIT: dili na mo-matter kung nag-necromancy ko bro as long as naa koy natabangan... dili ra kay nang-hambog nga kabalo ko.
Similar Threads |
|