How to do PHP unserialize jQuery serialized form data
The Jquery
The Jquery
serialize
method just takes the form elements and puts them in string form. example - "firstvariable=value&secondvariable=othervalue";
if you are not using associative array then
you can access this variable by $_GET and $_POST method.
Example =
$variable1 = $_GET['
firstvariable
'];
but if your data in an array then you need to unserialize jquery serialized data in php. you can unserialize jquery seralized data by usin this methods.
you can unserialize jquery serialize data into php by using parse_str.
//GET METHOD
$params = array();
parse_str($_GET, $params);
//POST METHOD
$params = array();
parse_str($_POST, $params);
if your data serialize data in a variable then you need to use-
$params = array();
parse_str($_POST['formdata'], $params);
you can also use this function to unserialize your data
function unserializeForm($str) {
$returndata = array();
$strArray = explode("&", $str);
$i = 0;
foreach ($strArray as $item) {
$array = explode("=", $item);
$returndata[$array[0]] = $array[1];
}
return $returndata;
}
Here is the super extra 20x fast server and cheap best and cheapest web hosting service to grow your big and small business on all search engine & get more sales or traffic, 70% blast discount, 24 hour live chat support.
ReplyDeleteInitial You got a awesome blog .I determination be involved in plus uniform minutes. i view you got truly very functional matters , i determination be always checking your blog blesss. currency converter website
ReplyDeleteThank you for sharing this informative post. looking forward to reading more.
ReplyDeleteBest PHP Development Services