Unusual get method in php

Hello, I have a question: how to pass multiple values ​​to a get?
For example, there is a link

http://www.dostavka.ru/request/ProductComparePageRequest?product_id=6490057-6553652-6582008

At the end, several IDs go to the product_idvalues, and they process them in their own way. The question itself is: how to correctly accept such a value and continue working with these IDs?


Answer 1, authority 100%

There are two fundamentally different ways.

  1. script.php?product_id=6490057-6553652-6582008

then

$produnct_ids = explode('-',$_GET['product_id']);  
//$produnct_ids[1] ==  6553652;
  1. script.php?product_id[]=6490057&product_id[]=6553652&product_id[]=6582008;

then

$produnct_ids = $_GET['product_id'];  
//$produnct_ids[1] ==  6553652;

The second way is preferable. Client side implementation:

<input type="text" name="produnct_id[]" value="6490057" /><br />
<input type="text" name="produnct_id[]" value="6553652" /><br />
<input type="text" name="produnct_id[]" value="6582008" /><br />

Pay attention to the brackets!!!

UPD
The resulting $product_ids arrays are identical. You can echo it like this:

echo '<pre>'.print_r($product_ids,true).'</pre>';

or like this:

echo implode(',',$product_ids);

or like this:

foreach($product_ids as $id){
  print($id.'<br />');
}

Answer 2, authority 50%

Why is it so difficult? :))))
I would do this:

http://www.dostavka.ru/request/ProductComparePageRequest?product_id=6490057,6553652,6582008

Server side:

if($_GET[product_id])
      $array_id = split(',',$_GET[product_id]); //      .

Next, we have an array with IDs.
and do whatever you want with them.