Thursday, September 17, 2009

basename() Function in PHP

The basename() function returns the filename from a path.


Structure: basename(path,suffix)

path, Required. Specifies the path to check.
suffix, Optional. Specifies a file extension. If the filename has this file extension, the file extension will not show.

Example:
$path = "/testweb/home.php";
//Show filename with file extension
echo basename($path) ."
“;
//Show filename without file extension
echo basename($path,”.php”);
?>
OUTPUT:
home.php
home


PHP  PHP Tutorial

 



Wednesday, September 16, 2009

Confused

I am in a confusion.........

Tuesday, September 15, 2009

PHP in_array() Function

in_array() is used to search for an array element through the array. It is the standard of  PHP4.
The basic construction of in_array ( ) is

in_array(element,array,type);

Here:
element, is the element to be searched.(Required Parameter)
array, is the given array in which we will make our search.(Required Parameter)
type, If this parameter is set, the in_array() function searches for the search-string and specific type in the array (Optional parameter).

Example:

  $fruit = array("apple", "mango", "orange");

if (in_array("apple",$fruit))
  {
  echo "Match found";
  }
else
  {
  echo "Match not found";
  }
?>

OUTPUT:
Match found









munir  hoque  in_array  php