0

I have a problem with Array_combine function. I want to combine prices to set as products keys. First I get everything as string from html form. and use explode function make it array. this process for both. Here it is a short of code;

    $urunler = $_POST['urunler'];
    $fiyatlar = $_POST['fiyatlar'];
    $products = explode(",", $urunler);
    $prices = explode(",", $fiyatlar);
    $dizi_birlestir = array_combine($prices, $products);

// OUTPUT
   [15] => first,
   [25] => second

// EXPECTED OUTPUT
   [10] => first,
   [15] => second,
   [25] => third
2
  • Can show values of $urunler and $fiyatlar? Commented Dec 7, 2019 at 15:24
  • hi buddy. Sorry to see your reply now. I've solved the problem. It was occurs because of array_combine(); I've changed array_combine($prices, $products) to array_combine($products,$prices); Commented Dec 8, 2019 at 9:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.