note 66103 rejected from function.list by bjori

From: Date: Mon, 15 May 2006 05:11:35 +0000
Subject: note 66103 rejected from function.list by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-111294@lists.php.net to get a copy of this message
Note Submitter: daevid at daevid dot com ---- 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; ?>

« previous php.notes (#111294) next »