note 97426 added to function.preg-match-all

From: Date: Mon, 19 Apr 2010 12:49:22 +0000
Subject: note 97426 added to function.preg-match-all
Groups: php.notes 
Request: Send a blank email to php-notes+get-168397@lists.php.net to get a copy of this message
3 regexp expressions to extract key, value and comment from ini file line : // Key name : preg_match_all('/(.*)\s*=\s*"(.*)"(.*)/U', $line, $arr, PREG_SET_ORDER); $key=$arr[0][1]; // Value : preg_match_all('/(.*)\s*=\s*"(.*)"\s*;\s*(.*)/U', $line, $arr, PREG_SET_ORDER); $value=$arr[0][2]; // Comments : preg_match_all('/"\s*;\s*(.*)/', $line, $arr, PREG_SET_ORDER); $comment=$arr[0][1]; Example : $line is : mykeyvalue = "this is my "value"" ; Comments here... $key will be: mykeyvalue $value will be: this is my "value" $comment will be: Comments here... Comment and value may include chars: " ; = Tested on : PHP Version 5.2.8 ---- Server IP: 69.147.83.197 Probable Submitter: 82.65.251.75 ---- Manual Page -- http://www.php.net/manual/en/function.preg-match-all.php Edit -- https://master.php.net/note/edit/97426 Del: integrated -- https://master.php.net/note/delete/97426/integrated Del: useless -- https://master.php.net/note/delete/97426/useless Del: bad code -- https://master.php.net/note/delete/97426/bad+code Del: spam -- https://master.php.net/note/delete/97426/spam Del: non-english -- https://master.php.net/note/delete/97426/non-english Del: in docs -- https://master.php.net/note/delete/97426/in+docs Del: other reasons-- https://master.php.net/note/delete/97426 Reject -- https://master.php.net/note/reject/97426 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#168397) next »