1
我需要使用php解析單引號文本(注意多個嵌套=單個),類似於論壇引用標記。例如:正則表達式引用標籤php
some nonquoted text1
[quote="person1"]some quoted text11[/quote]
some nonquoted text2
[quote="person2"]some quoted text22[/quote]
etc... with no newlines necessarily...
結果應該是像數組
Array
(
['nonquoted'] => Array
(
[0] => some unquoted text1
[1] => some unquoted text2
)
['quoted'] => Array
{
[0] => Array
(
[0] => person1
[1] => some quoted text11
)
[1] => Array
(
[0] => person2
[1] => some quoted text22
)
}
}
...和你嘗試過什麼? –
下面是一個讓你開始的例子,它只會匹配引用的內容,但它肯定不會創建你以後的漂亮結構:http://regex101.com/r/mN0yL1 –
索引數組應該是用於統一數據,異構數據應該是關聯數組。因此'$ array ['quoted']'中的內部數組應該像'Array('name'=>'person1','text'=>'some quoted text11')'。 – Barmar