November 13, 2009

Convert GET and POST to objects

Category: PHP, Tags: , , khadlock at 1:51 pm

Here's a quick way to convert GET and POST arrays to objects with PHP:

$get = (object)$_GET;
echo $get->sample;
$post = (object)$_POST;
echo $post->sample;

In this case the "sample" property would be an array key.

Bookmark and Share

Leave a Reply