Looking for suggestions as to the best way to do this (I know there are many options):
take a variable like this:
$args = ('post_type=post&order_by=DESC&limit=10');
the create a function to convert that variable into parts like this:
$post_type = post;
$order_by = DESC;
$limit= 10;
Reason is I want a client to be able to use a string like the first to pass variables to a sql query in much the same way (but doesn't have to be exact) as you can do it in WordPress.
You might want to take a look at
and
parse_str() ( in your case it's more parse_str()
but you'll need the first one for "doing the opposite" )
I think the parse_str
function can help you.
$query = parse_str($args);
$post_type = $query['post_type'];
$order_by = $query['order_by'];
$limit = $query['limit'];