I created a function to convert PHP Object to Array.
The main function remove unnecessary data from the object.
Second loop gives you straight array. You can manipulate it as you want to display PHP Array data.
function phpObjectToArray($phpObject)
{
if(!is_object($phpObject) && !is_array($phpObject))
return $phpObject;
$phpArray=array();
foreach($phpObject as $member=>$data)
{
$phpArray[$member]=phpObjectToArray($data);
}
return $phpArray;
}
$scopeArray = phpObjectToArray($show_scope_data);
echo"";
print_r($scopeArray);
Output after passing object.
Array
(
[0] => Array
(
[data] => Array
(
[ekey] => 1
[ecode] => UNKNOWN
[ename] => Unknown Name
[edesc] => Name has an unknown scope
[flag] => 1
)
)
[1] => Array
(
[data] => Array
(
[ekey] => 2
[ecode] => GLOBAL
[ename] => This Scope Name
[edesc] => Name applies to all sites
[flag] => 1
)
)
[2] => Array
(
[data] => Array
(
[ekey] => 3
[ecode] => PHPMIND
[ename] => PHPMIND Scope Name
[edesc] => PHPMIND applies to all tuto
[flag] => 1
)
)
[3] => Array
(
[data] => Array
(
[ekey] => 4
[ecode] => PHP Technology
[ename] => PHP Technology Scope Name
[edesc] => PHP Technology applies to all tuto
[flag] => 1
)
)
[4] => Array
(
[data] => Array
(
[ekey] => 5
[ecode] => CSS2
[ename] => CSS2 Scope Name
[edesc] => CSS2 applies to all css2 tuto
[flag] => 1
)
)
[5] => Array
(
[data] => Array
(
[ekey] => 6
[ecode] => HTML5
[ename] => HTML5 Scope Name
[edesc] => HTML5 Name applies to a HTML5 tuto
[flag] => 1
)
)
)
$array_list = array();
foreach($scopeArray as $key=>$value)
{
$array_list[$key]= $scopeArray[$key]["data"];
}
print_r($array_list);
Last print_r() function will display normal array.
Very Nice Explanation
Excellent
Thank you very much!…