How to split a comma separated string into groups of 2 each and then convert all these groups to an array <p>I have a string which is like <code>1,2,2,3,3,4</code> etc. First of all, I want to make them into groups of strings like <code>(1,2),(2,3),(3,4)</code>. Then how I can make this string to array like<code>{(1,2) (2,3) (3,4)}</code>. Why I want this is because I have a array full of these 1,2 etc values and I've put those values in a <code>$_SERVER['query_string']="&amp;exp=".$exp</code>. So Please give me any idea to overcome this issue or solve.Currently this is to create a group of strings but again how to make this array.</p> <pre><code>function x($value) { $buffer = explode(',', $value); $result = array(); while(count($buffer)) { $result[] = sprintf('%d,%d', array_shift($buffer), array_shift($buffer)); } return implode(',', $result); } $result = x($expr); </code></pre> <p>but its not working towards my expectations</p>