note 66103 added to function.list
| From: | daevid at daevid dot com | Date: | Mon, 15 May 2006 00:45:39 +0000 |
| Subject: | note 66103 added to function.list | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-111283@lists.php.net to get a copy of this message | ||
There is an annoying bug I think in that this will not give the desired results:
say you have this format:
00:01:02:03:04:05 linux daevid.com
<?php
preg_match("/(..:..:..:..:..:..)\s(\w+)\s+(.*)/", $map[$i], $matches);
unset($matches[0]);
//var_dump($matches);
list($mac, $image, $name) = $matches;
?>
notice how even though I unset the [0] element, and the array appears properly, it seems that the
list() starts from 0 even if one doesn't exist or something... Anyways, your variables will NOT
have the right things in them, they'll be shifted. $mac will be empty, $image will have the
mac, etc.
you have to do this (and basically have a throw away place holder):
<?php
preg_match("/(..:..:..:..:..:..)\s(\w+)\s+(.*)/", $map[$i], $matches);
//var_dump($matches);
list($junk, $mac, $image, $name) = $matches;
//or you could do this too (note the empty , slot):
list(, $mac, $image, $name) = $matches;
?>
----
Server IP: 64.71.164.2
Probable Submitter: 24.16.16.159
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.list.php
Edit -- http://master.php.net/note/edit/66103
Del: integrated -- http://master.php.net/note/delete/66103/integrated
Del: useless -- http://master.php.net/note/delete/66103/useless
Del: bad code -- http://master.php.net/note/delete/66103/bad+code
Del: spam -- http://master.php.net/note/delete/66103/spam
Del: non-english -- http://master.php.net/note/delete/66103/non-english
Del: in docs -- http://master.php.net/note/delete/66103/in+docs
Del: other reasons-- http://master.php.net/note/delete/66103
Reject -- http://master.php.net/note/reject/66103
Search -- http://master.php.net/manage/user-notes.php