使用非序列化php数组解析图像数组
对一些人来说,这可能是一个简单的问题,但不幸的是,对我来说不是。。 我正在从MySql数据库检索序列化数组。那很好。它很好。 然后,我将检索需要按未序列化数组的顺序显示的图像数组:使用非序列化php数组解析图像数组,php,arrays,serialization,multidimensional-array,Php,Arrays,Serialization,Multidimensional Array,对一些人来说,这可能是一个简单的问题,但不幸的是,对我来说不是。。 我正在从MySql数据库检索序列化数组。那很好。它很好。 然后,我将检索需要按未序列化数组的顺序显示的图像数组: $order = unserialize( $row['displayOrder']); 这将导致: Array ( [0] => 2296543905 [1] => 2296540032 [2] => 2296540820 [3] => 2296541625 [4] => 22965
$order = unserialize( $row['displayOrder']);
这将导致:
Array ( [0] => 2296543905 [1] => 2296540032 [2] => 2296540820 [3] => 2296541625 [4] => 2296541997 [5] => 2296542417 [6] => 2296542816 [7] => 2296543113 [8] => 2296545096 [9] => 2296544278
我正在检索另一个图像URL数组,如下所示:
$images = $images['Images'];
foreach ( $images as $index => $image) {
echo '<li><img src="'.$image['TinyURL'].'" class="framed"></li>';
}
我的问题是…如何解析以使imagesTinyURL按未序列化数组的顺序显示?
i、 e:按
图像
数组中的id
按顺序
数组列出图像URL?以下是一个小示例:
//Create an array where the keys are image ids
$imageArray=array();
foreach($images as $image)
$imageArray[$image['id']]=$image;
//Output the images according to the order array (array of image ids)
foreach($order as $id){
print_r($imageArray[$id]);
}
下面是一个小例子:
//Create an array where the keys are image ids
$imageArray=array();
foreach($images as $image)
$imageArray[$image['id']]=$image;
//Output the images according to the order array (array of image ids)
foreach($order as $id){
print_r($imageArray[$id]);
}
也许是前者的一个小例子?事实上,我只是编辑它来做同样的事情,没有任何排序函数=)工作起来就像一个众所周知的魅力…谢谢!!也许是前者的一个小例子?事实上,我只是编辑它来做同样的事情,没有任何排序函数=)工作起来就像一个众所周知的魅力…谢谢!!