maliary Posted July 25, 2007 Share Posted July 25, 2007 Hi, I have the following string - &=120=-&=127=-&=131=-&=135=-&=170=-&=171=-&=174=-&=175=-&=194=-&=196=-&=206=-&=222=-&=230=-&=236=-&=237=-&=240=-&=249=9 249=9 The important part are the numbers e.g. 120,127 and the dash or value after the = and before the & e.g. 236= (-) & The red part. I would like to separete them to get to display the dash only. how would I do this? Quote Link to comment Share on other sites More sharing options...
Barand Posted July 25, 2007 Share Posted July 25, 2007 try <?php $str = '&=120=-&=127=-&=131=-&=135=-&=170=-&=171=-&=174=-&=175=-&=194=-&=196=-&=206=-&=222=-&=230=-&=236=-&=237=-&=240=-&=249=9'; $ar = explode ('&=', $str); $results = array(); foreach ($ar as $val) { if ($val) { list($k,$v) = explode ('=', $val); $results[$k] = $v; } } echo '<pre>', print_r($results, true), '</pre>'; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.