Hi, I want to know how to split a string such as "C:\my documents\mydoc.pdf". I want to split the string after the '.', so that I have two strings:<br><br>string 1 = C:\my documents\mydoc<br>string 2 = .pdf<br><br>Thanks..<br><br>Mike
Allright, we will try to consider the problem with different points of view. You can treat this problem in several ways.<br><br>------------------------------------------------------------<br><br>First of all, you probably want to get the extension, so you need the only 3 last characters of the string. This is a code to make it :<br><br>$string_1 = "C:\my documents\mydoc.pdf";<br>$string_2 = ereg( "\.???$", $string_1 );<br><br>That will result the following variable :<br>$string_2 == ".pdf"<br><br>Note : I am not sure of the regular expression used, so check it ! ;-)<br><br>------------------------------------------------------------<br><br>But you could choose to get all that is after the "." by this way :<br><br>$string_1 = C:\my documents\mydoc.pdf;<br>$string_2 = explode( ".", $string_1 );<br><br>Taht will result the following array :<br>$string_2[0] == "C:\my documents\mydoc";<br>$string_2[1] == ".pdf";<br><br>Note : as you can use the explode() function, you can use split().<br><br>------------------------------------------------------------<br> <p>Cédric CHERCHI<br><a href=mailtoochacco@francemail.com>pochacco@francemail.com</a><br><a href= > </a><br>PHP/MySQL<br>
JavaScript<br>
Flash 4 scripting<br>
HTML/DHTML
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.