note 81862 added to function.extract
| From: | benjaminATwebbutvecklarnaDOTse at osu1 dot php dot net | Date: | Mon, 17 Mar 2008 03:15:28 +0000 |
| Subject: | note 81862 added to function.extract | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-137116@lists.php.net to get a copy of this message | ||
In the meantime, I'm using this:
// extract alternative
# extracts variables where new value is above the threshold or if old value is on or below the
threshold (or var is not defined)
# an associative array is obviously the sane thing to pass
#
# I am absolutely certain someone will find obvious problems or errors with this
# I haven't even tried to compare other values than 0 so if you need to do that and surely
finds obvious flaws,
# please mail me, I'd really like to know.
# benjaminATwebbutvecklarnaDOTse
// usage example:
# thrextract(mysql_fetch_assoc(mysql_query("SELECT preset_this,preset_that FROM site_preset
WHERE ID = $site_id")));
# thrextract(mysql_fetch_assoc(mysql_query("SELECT preset_this,preset_that FROM category_preset
WHERE ID = $category_id")));
function thrextract($arr,$thr = 0){
foreach($arr as $key => $var){
global $$key;
if($var > $thr or $$key <= $thr) $$key = $var;
}
}
----
Server IP: 212.63.193.10
Probable Submitter: 85.229.97.52
----
Manual Page -- http://www.php.net/manual/en/function.extract.php
Edit -- https://master.php.net/note/edit/81862
Del: integrated -- https://master.php.net/note/delete/81862/integrated
Del: useless -- https://master.php.net/note/delete/81862/useless
Del: bad code -- https://master.php.net/note/delete/81862/bad+code
Del: spam -- https://master.php.net/note/delete/81862/spam
Del: non-english -- https://master.php.net/note/delete/81862/non-english
Del: in docs -- https://master.php.net/note/delete/81862/in+docs
Del: other reasons-- https://master.php.net/note/delete/81862
Reject -- https://master.php.net/note/reject/81862
Search -- https://master.php.net/manage/user-notes.php