note 91272 added to function.array
| From: | kamil at navikam dot pl | Date: | Wed, 03 Jun 2009 10:42:09 +0000 |
| Subject: | note 91272 added to function.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-156310@lists.php.net to get a copy of this message | ||
Easy function to unarray an array :-)
It will make $array['something'] => $something.
Usefull for making code more clear.
example of use:
<?
function unarray($row) {
foreach($row as $key => $value) {
global $$key;
$$key = $value;
}
}
$sql = mysql_query("SELECT * FROM
pracownicy");
while ($row = mysql_fetch_assoc($sql)) {
unarray($row);
echo $idpracownika.'<br>'; //instead of $row['idpracownika']
}
?>
----
Server IP: 82.177.164.100
Probable Submitter: 83.30.136.109
----
Manual Page -- http://www.php.net/manual/en/function.array.php
Edit -- https://master.php.net/note/edit/91272
Del: integrated -- https://master.php.net/note/delete/91272/integrated
Del: useless -- https://master.php.net/note/delete/91272/useless
Del: bad code -- https://master.php.net/note/delete/91272/bad+code
Del: spam -- https://master.php.net/note/delete/91272/spam
Del: non-english -- https://master.php.net/note/delete/91272/non-english
Del: in docs -- https://master.php.net/note/delete/91272/in+docs
Del: other reasons-- https://master.php.net/note/delete/91272
Reject -- https://master.php.net/note/reject/91272
Search -- https://master.php.net/manage/user-notes.php