note 101618 added to function.preg-match

From: Date: Thu, 30 Dec 2010 14:12:31 +0000
Subject: note 101618 added to function.preg-match
Groups: php.notes 
Request: Send a blank email to php-notes+get-175332@lists.php.net to get a copy of this message
This sample regexp may be useful if you are working with DB field types. (?P<type>\w+)($|\((?P<length>(\d+|(.*)))\)) For example, if you are have a such type as "varchar(255)" or "text", the next fragment <?php $type = 'varchar(255)'; // type of field preg_match('/(?P<type>\w+)($|\((?P<length>(\d+|(.*)))\))/', $type, $field); print_r($field); ?> will output something like this: Array ( [0] => varchar(255) [type] => varchar [1] => varchar [2] => (255) [length] => 255 [3] => 255 [4] => 255 ) ---- Server IP: 195.54.192.44 Probable Submitter: 127.0.0.1 ---- Manual Page -- http://www.php.net/manual/en/function.preg-match.php Edit -- https://master.php.net/note/edit/101618 Del: integrated -- https://master.php.net/note/delete/101618/integrated Del: useless -- https://master.php.net/note/delete/101618/useless Del: bad code -- https://master.php.net/note/delete/101618/bad+code Del: spam -- https://master.php.net/note/delete/101618/spam Del: non-english -- https://master.php.net/note/delete/101618/non-english Del: in docs -- https://master.php.net/note/delete/101618/in+docs Del: other reasons-- https://master.php.net/note/delete/101618 Reject -- https://master.php.net/note/reject/101618 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#175332) next »