array_unshift ($ids,$product_id => $catalog_tag);
if i put
array($product_id => $catalog_tag)
would work but wont add $product_id as key.. I want to add it at the start
array_unshift ($ids,$product_id => $catalog_tag);
if i put
array($product_id => $catalog_tag)
would work but wont add $product_id as key.. I want to add it at the start
This code takes your array noting that it's using integer keys for your array so these will always be the array order, so we convert them to string keys and this prevents the key's acting as the order of the array. we then create the a new array with your value and append all values from your existing array to the end.
note that the product ID is converted to a string again to prevent the integer key from ordering the array.
$ids = array(0 => "bla bla", 1 => "bla bla", 2 => "bla bla", 3 => "bla bla")
foreach($ids as $key => $val){
$key = "$key";
}
unset(current($ids));
$ids = array_merge(array("$product_id" => $catalog_tag), $ids);