http_build_query
-
This function’s solution will only work within the context of the Rails framework.
PHP’s
http_build_queryfunction provides a convenient way to generate URL-encoded query strings from associative arrays.PHP
$data = array('foo' => array('bar' => 'baz')); $query = http_build_query($data); var_export($query); //=> 'foo%5Bbar%5D=baz'
In Rails, we can use ActiveSupport’s
Hash#to_querymethod.Rails
data = {:foo => {:bar => 'baz'}} p data.to_query #=> "foo%5Bbar%5D=baz"
see also
Looking for Rails or PHP web application development, integration, and training?
Rails for PHP is brought to you by Maintainable Software. Get custom web applications and personalized training from the authors of the book and website.

