access the values passed to a function?how

Use the names from the function prototype:
function commercial_sponsorship($letter, $number) { 
    print "This episode of Sesame Street is brought to you by ";
    print "the letter $letter and number $number.\n";
}

commercial_sponsorship('G', 3);
commercial_sponsorship($another_letter, $another_number);

how associate multiple elements with a single key?

Store the multiple elements in an array:
$fruits = array('red' => array('strawberry','apple'),
                'yellow' => array('banana'));
Or, use an object:
while ($obj = mysql_fetch_object($r)) {
    $fruits[ ] = $obj;
}

How to check whether two floating-point numbers are equal?

Use a small delta value, and check if the numbers are equal within that delta:
$delta = 0.00001;

$a = 1.00000001;
$b = 1.00000000;

if (abs($a - $b) < $delta) { /* $a and $b are equal */ }

You want to extract part of a string, starting at a particular place in the string

Use substr( ) to select your substrings:
$substring = substr($string,$start,$length);
$username = substr($_REQUEST['username'],0,8);

Php get_meta_tags-Extracts all meta tag content attributes

get_meta_tagsExtracts all meta tag content attributes from a file and returns an array

<?php// Assuming the above tags are at www.example.com$tags get_meta_tags('http://www.example.com/');
// Notice how the keys are all lowercase now, and
// how . was replaced by _ in the key.
echo $tags['author'];       // nameecho $tags['keywords'];     // php documentationecho $tags['description'];  // a php manualecho $tags['geo_position']; // 49.33;-86.59?>

PHP Redirect - Redirect Script?

PHP Redirect Function

header('Location:  destination.php');
exit();
 
ou need the Location: part so the browser knows what header it's 
receiving. Also, don't forget to 
do an exit() or die() right after the redirect. 

 

Finding the Position of a Value in an Array

Use array_search( ) . It returns the key of the found value. If the value is not in the array, it returns false:
 
$position = array_search($value, $array);
if ($position !== false) {
    // the element in position 
//$position has $value as its 
//value in array $array
}
 
Use in_array( ) to find if an array contains a value; use array_search( ) to discover where that value is located. However, because array_search( ) gracefully handles searches in which the value isn't found, it's better to use array_search( ) instead of in_array( ). The speed difference is minute, and the extra information is potentially useful:

$favorite_foods = array(1 => 'artichokes', 'bread', 'cauliflower', 'deviled eggs');
 $food = 'cauliflower'; $position = array_search($food, $favorite_foods);
 if ($position !== false)
{
echo "My #$position favorite food is $food";
}
 else {
 echo "Blech! I hate $food!";
 }


Use the !== check against false because if your string is found in the array at position 0, the if evaluates to a logical false, which isn't what is meant or wanted.
If a value is in the array multiple times, array_search( ) is only guaranteed to return one of the instances, not the first instance.
 

Turning an Array into a String

convert it into a  formatted string.
Use join( ):
// make a comma delimited list
$string = join(',', $array);

Or loop yourself:
$string = '';

foreach ($array as $key => $value) {
    $string .= ",$value";
}

$string = substr($string, 1); // remove leading ","
 
 
If you can use join( ), do; it's faster than any PHP-based loop. However, join( ) isn't very flexible. First, it places a delimiter only between elements, not around them. To wrap elements inside HTML bold tags and separate them with commas, do this:
$left = '<b>'; $right = '</b>'; $html = $left . join("$right,$left", $html) . $right;
Second, join( ) doesn't allow you to discriminate against values. If you want to include a subset of entries, you need to loop yourself:
$string = ''; foreach ($fields as $key => $value) { // don't include password if ('password' != $key) { $string .= ",<b>$value</b>"; } } $string = substr($string, 1); // remove leading ","
 

Setting Environment Variables

Setting environment variables in your server configuration
on a host-by-host basis allows you to configure virtual hosts differently.

<?php
putenv('ORACLE_SID=ORACLE'); // configure oci extension
?>
 

Adjusting behavior based on an environment variable

 <?php
$version = $_SERVER['SITE_VERSION'];

// redirect to http://guest.example.com, 
//if user fails to sign in correctly
if ('members' == $version) {
    if (!authenticate_user($_POST['username'], $_POST['password'])) {
        header('Location: http://guest.example.com/');
        exit;
    }
}
include_once "${version}_header"; // load custom header

http://www.php.net/putenv; information on setting environment 
variables in Apache at