[英]get strings in array from another string by matching pattern
我有一個如下所示的字符串:
$str = "`col1` int(4) NOT NULL,`column2` varchar(45),`someothercol` text,";
我想要列名列表,即介於兩者之間的任何內容
`**`
該數組應包括
array("col1","column2","someothercol");
使用preg_match_all :
$str = "`col1` int(4) NOT NULL,`column2` varchar(45),`someothercol` text,";
$arr = preg_match_all('/`(\w+)`/', $str, $matches);
print_r($matches[1]);
輸出:
Array
(
[0] => col1
[1] => column2
[2] => someothercol
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.