Home | Add to Favorites | Ebooks Directory | News  
PHP  Script programming
Home
PHP  Article
PHP Tutorial 
PHP Script  Download
Books
PHP Manual
PHP Resource
PHP Tutorial

12.To display filename and extension separately.
   
 

 

   The preg_split() function splits the input string according to the matching pattern specified in it and returns    an array of elements in which each element is the split string .
   The first element of the array will contain the first split, the second one the second split string and so on...


 

<?php
   $url=$_POST['url'];
   $filename=basename($url);
   $file_arr=preg_split("/\./",$filename);
   $name=$file_arr[0];
   $ext=$file_arr[1];
   ?>



   <html>
   <form name="frm" method="post">
   Enter the filename with extension : <input type="text" name="url"  size=25>
   <br>
   
   <input type="submit" name="submit">
   <?php
   

   if($_POST)
   {
           echo "<br><font color=green size=5 >The FileName specified in the URL is $filename<br><br>The filename is $name<br><br>The extension is
.$ext<br></font>";
   }
   ?>
   </form>
   </html>

 

                                                         Go To Index