我想格式化数组,我有这个例子:$articletxt = 'Hello! this is my picture But I look better in real life
Hello! this is my picture But I look better in real life';
preg_match_all('/]+>/i',$articletxt, $formatbusquedas);
$img = array();
foreach( $formatbusquedas[0] as $img_tag) {
preg_match_all('/(type|name|data)=("[^"]*")/i',$img_tag, $img[$img_tag]);
}
echo '
';
print_r($img);
它将打印出来:Array
(
[] => Array
(
[0] => Array
(
[0] => tipo="table"
[1] => name="My Picture"
[2] => data="http://www.example.com/myimage.jpg"
)
[1] => Array
(
[0] => tipo
[1] => name
[2] => data
)
[2] => Array
(
[0] => "table"
[1] => "My Picture"
[2] => "http://www.example.com/myimage.jpg"
)
)
[] => Array
(
[0] => Array
(
[0] => tipo="youtube"
[1] => name="Unlock Samsung S5310 Galaxy Pocket Neo by USB"
[2] => data="piHMEZlAAmA"
)
[1] => Array
(
[0] => tipo
[1] => name
[2] => data
)
[2] => Array
(
[0] => "youtube"
[1] => "Unlock Samsung S5310 Galaxy Pocket Neo by USB"
[2] => "piHMEZlAAmA"
)
)
)
但是我需要这样:Array
(
[] => Array
(
[tipo] => table
[name] => My Picture
[data] => http://www.example.com/myimage.jpg
)
[] => Array
(
[tipo] => youtube
[name] => Unlock Samsung S5310 Galaxy Pocket Neo by USB
[data] => piHMEZlAAmA
)
)
如何制作?