我有一个这样的字符串。
$string = "title1|1.99|www.website.com|www.website.com/img1.jpg|title2|5.99|www.website2.com|www.website2.com/img2.jpg|title3|1.99|www.website3.com|www.website3.com/img3.jpg|";
我希望将字符串分解为一个数组,但每 4 个管道实例创建一个新数组。也可以很好地命名键,如下所示。
例如:
array (
[title] => title1
[price] => 1.99
[url] => www.website.com
[gallery] => www.website.com/img1.jpg
)
array (
[title] => title2
[price] => 5.99
[url] => www.website2.com
[gallery] => www.website2.com/img2.jpg
)
等等...
我怎样才能实现这一目标?