I have this json encoded array
requestparser.php
$array = array("ph" => array("phweb" => "yes", "phemail" => "yesss"));
echo json_encode($array);
and ajax post type request for sending and processing the return response.
$.ajax({
type: 'POST',
url: 'requestparser.php',
data: { "request" : "pull" },
contentType: "application/json; charset=utf-8",
dataType: 'json',
cache: false,
success: function(result) {
alert(result["ph"]["phweb"]);
alert(result["ph"]["phemail"]);
}
});
what I'm trying to do is to get the array key and filter it with if statement, like (refer below)
var thearraykey = array key
if (thearraykey === "ph"){
alert(array key)
}
how to get the array key that was in the json encoded response from requestparser.php? any help, ideas and clues would be greatly appreciated.