I have an array with custom key value, not incremental e.g.
$array_same_cat = array("SF124" => "value", "XA127" => "value2", "AT257" => "value3");
Now what I am working on is to search having a key value (XA127) the previous key and the next key and their value.
Here below the code that generate the array:
$array_same_cat = array();
if($loop_arrows->have_posts()){
while($loop_arrows->have_posts()){
$loop_arrows->the_post();
$current_id = get_the_ID();
$this_prod_sku = get_post_meta( $current_id, '_sku', true );
$array_same_cat[$this_prod_sku] = esc_url(get_permalink(intval($this_prod_sku)));
}
}
Added this With this foreach I found the exact position of my element. Now I have to find how to do prev and next.
foreach($array_same_cat as $ar){
if($ar == $array_same_cat[$current_sku]){
echo 'found';
}
}