php - Single url variable with multiple values into array -


this question has answer here:

i have url single variable (category), variable has multiple values.

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

i'd generate array information.

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

print_r reveals this:

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

here's need like:

    $category = array('cat','dog','rabbit','-cow'); 

have tried...

$categories = explode(' ', $_get['category']); 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -