0

I have a url with a single variable (category), but the variable has multiple values.

Example: http://websiteurl.com/?category=cat+dog+rabbit+-cow

I'd like to generate an array with this information.

    <?$category[] = $_GET['category'];?>

print_r reveals this:

    $category = Array ( [0] => cat dog rabbit -cow )

Here's what I need that to look like:

    $category = array('cat','dog','rabbit','-cow');
mdcrtv
  • 143
  • 2
  • 10

1 Answers1

3

Have you tried...

$categories = explode(' ', $_GET['category']);
diggersworld
  • 11,830
  • 21
  • 77
  • 115