Jump to content

Darkwoods

Members
  • Posts

    88
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Darkwoods's Achievements

Member

Member (2/5)

0

Reputation

1

Community Answers

  1. Yes this is how I managed to do it but not so sure if it looks good.. but it works $text = 'cat1=hello,world|cat2=one,two|cat3=value1,value2'; $arr= explode('|', $text); foreach($arr as $value) { $key = rtrim(stristr($value, '=', true), '='); $values = ltrim(stristr($value, '='), '='); $values = explode(',', $values); $array[$key] = $values; } print_r($array);
  2. Im trying to parse/convert this string using delimiters = , | $text = 'cat1=hello,world|cat2=one,two|cat3=value1,value2'; Into an array like this: Array( [cat1] => Array ( [0] => hello [1] => world ) [cat2] => Array ( [0] => one [1] => two ) [cat3] => Array ( [0] => value1 [1] => value2 ) ) any suggestion on how to achieve this ?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.