我有一个文本块,我需要在其中找到一些文本,例如:{slider:1} {video-alt:10}
我有这段代码
$regex = '/{[ ]*(slider)|(slider-alt)|(video)[ ]*:[0-9]+[ ]*}/';
$matches = array();
preg_match_all( $regex, $row->content, $matches );
但是返回的数组全乱了...
数组输出:
Array ( [0] => {slider [1] => {slider [2] => video:2} )
Array ( [0] => slider [1] => slider [2] => )
Array ( [0] => [1] => [2] => )
Array ( [0] => [1] => [2] => video )
对于输入:
{slider:6}
{slider-alt:2}
{video:2}
有什么帮助吗?