I have string data
$pages = "mangaName=&authorArtist=asdas123s&genres=sn&genres[23]=on&genres[29]=on&status=&chrome=&submit=+";
function get_h1($file){
$h1tags = preg_match_all('/\[(\w*)\]/is',$file,$patterns);
$res = array();
array_push($res,$patterns[2]);
array_push($res,count($patterns[2]));
return $res;
}
i want get number on genres[23] , genres[29]
[0] => 23 [1] => 29
$pages = "mangaName=&authorArtist=asdas123s&genres=sn&genres[23]=on&genres[29]=on&status=&chrome=&submit=+";
parse_str($pages, $parsed);
var_dump(array_keys($parsed['genres'])); // array(2) { [0]=> int(23) [1]=> int(29) }
zerkms' answer is the right one, but if you really want to use regexp, change yours with this one:
preg_match_all('/\[(\w*?)\]/is',$file,$patterns);
note the non-greedy __^
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.