|
Home
iRate! IceMelon IM Tutorials Headlines CoolSites PHP Functions |
|
Most Referenced Functions » google_pagerank() » preg_replace() » site_pageranks() » imagecreatefrompng() » htmlentities() » imagepng() » imagestring() » imagedestroy() » preg_match() » imagecolorallocate() » header() » session_start() » fopen() » getimagesize() » strpos() » strstr() » preg_match_all() » ob_start() » nl2br() » array2vars() » ob_flush() » str_replace() » flush() » htmlspecialchars() » setcookie() » urlencode() » ereg() » preg_split() » ereg_replace() » var_dump() Our Sponsors » Weblog Community » Rock Music Community - meet fans » Furniture Stores Allentown Become a sponsor for $15/month. Link is sitewide - PR5 homepage, 20+ PR4 pages, 90+ PR3 pages. Email dave[AT]icemelon[D0T]c0m.
Local search Connecticut furniture stores can be found at FurnitureCatch:
Furniture Stores Norwalk,
Furniture Stores Stamford,
Furniture Stores Greenwich,
Furniture Stores New Canaan,
Furniture Stores Darien
|
PHP Functions
Function: array2vars By dave Note! This function is not a built-in PHP function. To use it, you will need to copy the source code (located at the bottom of this page) into your script. array2vars -- Converts an array into a set of variables, where the keys become the variables' names. Descriptionvoid array2vars ( array KeysWithValues )This function can be useful in converting your $_POST values into distinct variables. This way, you can just type $keyName instead of $_POST['keyName']. Other similar arrays include $_GET, $_REQUEST, $_SESSION, $_COOKIE; and an array (or row) fetched from your mySQL database, as exemplified in example 2. Note! It was pointed out by a visitor that the function extract (see related functions) does the exact same thing. Example 1. array2vars() example
<?php
$icemelon = Array('ice' => 'melon', 'foo' => 'fighters');
array2vars($icemelon);
echo "$ice, $foo "; // outputs: melon, fighters
?>
Example 2.
<?php
$q = mysql_query($query);
while($row = mysql_fetch_array($q)) {
array2vars($row);
// use variables
// ....
}
?>
Source Code
<?php
function array2vars($arr) {
foreach($arr AS $key=>$var) {
global $$key;
$$key = $var;
}
}
?>Related Function(s) |