note 90696 added to function.mysql-field-flags

From: Date: Tue, 05 May 2009 10:00:01 +0000
Subject: note 90696 added to function.mysql-field-flags
Groups: php.notes 
Request: Send a blank email to php-notes+get-154217@lists.php.net to get a copy of this message
To parse an enum/set type correctly, including strings like ENUM('a\'b','c'), here is an almost pcre-free way that works well. <?php function parse_enum_values($typestr) { // remove ENUM/SET part $typestr = preg_replace('/^(enum|set)/i', '', $typestr); // trim '(', ')', ' off the ends of the string and then explode it on ',' return trim(explode("','", $typestr), "(')"); } ?> It works because explode is looking for ',' - not ',\'. ---- Server IP: 117.104.162.229 Probable Submitter: 58.96.44.86 (proxied: 58.96.44.86) ---- Manual Page -- http://www.php.net/manual/en/function.mysql-field-flags.php Edit -- https://master.php.net/note/edit/90696 Del: integrated -- https://master.php.net/note/delete/90696/integrated Del: useless -- https://master.php.net/note/delete/90696/useless Del: bad code -- https://master.php.net/note/delete/90696/bad+code Del: spam -- https://master.php.net/note/delete/90696/spam Del: non-english -- https://master.php.net/note/delete/90696/non-english Del: in docs -- https://master.php.net/note/delete/90696/in+docs Del: other reasons-- https://master.php.net/note/delete/90696 Reject -- https://master.php.net/note/reject/90696 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#154217) next »