我有不同的參數...在產品上...但我只想顯示那些被用戶點擊的參數。我做了這個,但我想刪除duplicacy ..我的代碼是: -從for循環中的數組中刪除重複的ID
$ab=$_POST['data1'];
$karan=explode(",",$ab);
array_pop($karan);
for($i=0;$i<count($karan);$i++){
'karan['.$i.'] = '.$karan[$i];
$posts = $wpdb->get_results("SELECT * FROM demo_postmeta WHERE meta_value='".$karan[$i]."' ");
$out=array();
foreach($posts as $post){
if (!isset($out[$post->post_id])){
$out[$post->post_id][$post->meta_key]=$out;
$ram=get_the_post_thumbnail($post->post_id,"_thumbnail_id",true);
$title=get_post_meta($post->post_id,"_product_title",true);
$price=get_post_meta($post->post_id,"_product_year",true);
$link=get_post_meta($post->post_id,"_product_likes",true);
?>
<div id="itemListContent" class="in-list">
<div class="the-list">
<div class="li first row clearfix" style="cursor: pointer;">
<div class="c-1 table-cell">
<div class="cropit">
<a class="pics-lnk important-rule" href="http://uzodocs.com/PROJECTS/demo/products?post_id=<?php echo $post->post_id ?>" style="text-decoration: none;">
<?php echo $ram; ?>
</a>
</div>
</div>
<div class="second-column-container table-cell">
<h3>
<a href="http://uzodocs.com/PROJECTS/demo/products?post_id=<?php echo $post->post_id ?>" title="Kenxinda Watch Mobile Dual SIM with FREE Bluetooth Headset free home delivery - Delhi" class="important-rule" style="text-decoration: none;">
<?php echo $title; ?>
</a>
</h3>
<div class="c-4">
</div>
<span class="itemlistinginfo clearfix">
<span>
Delhi |
Cameras
- Camera Accessories
</span>
<span>
</span>
</span>
</div>
<div class="third-column-container table-cell">
<?php echo $price; ?>
</div>
<div class="fourth-column-container table-cell"><br> </div>
</div>
<div class="li even row clearfix" style="cursor: pointer;">
<div class="c-1 table-cell">
</div>
</div>
</div>
</div>
<?php
}
$out[$post->post_id][$post->meta_key][] = $post->post_id;
}
}
die;
?>
array_unique不在這個工作.. – user3247958
那麼哪個變量包含重複? – rinukkusu
http://uzodocs.com/PROJECTS/demo/go/檢查此鏈接並檢查複選框 – user3247958