0

I have an data array where i am getting results as var_dump($get_data);

array(45) {
    ["sitelock"] => array(4) {
        [181] => array(2) {
            ["plan_name"] => string(10) "Enterprise" 
            ["plan_status"] => string(6) "Active"
        } 
        [180] => array(2) {
            ["plan_name"] => string(7) "Premium" 
            ["plan_status"] => string(6) "Active"
        } 
        [179] => array(2) {
            ["plan_name"] => string(12) "Professional" 
            ["plan_status"] => string(6) "Active"
        } 
        [178] => array(2) {
            ["plan_name"] => string(5) "Basic" 
            ["plan_status"] => string(6) "Active"
        }
    } 
    ["codeguard"] => array(4) {
        [230] => array(2) {
            ["plan_name"] => string(12) "Professional" 
            ["plan_status"] => string(6) "Active"
        } 
        [229] => array(2) {
            ["plan_name"] => string(5) "Basic" 
            ["plan_status"] => string(6) "Active"
        } 
        [232] => array(2) {
            ["plan_name"] => string(10) "Enterprise" 
            ["plan_status"] => string(6) "Active"
        } 
        [231] => array(2) {
            ["plan_name"] => string(7) "Premium" 
            ["plan_status"] => string(6) "Active"
        }
    }
}

Step 1 = I would like to filter sitelock from an array than i want to display it's key value 181,180,179,178 as pid in list and ["plan_name"] values are respectively as Enterprise, Premium, Professional, Basic

Here is expected result example:

pid  Plan Name
181  Enterprise
180  Premium
179  Professional
181  Enterprise
181  Basic

So far I am trying something like this

$get_data = json_decode($data,true);
//var_dump( $get_data);
$productkey = "sitelock";
foreach($get_data as $key => $value) {
    if($key == $productkey) {
        // table code goes here
    }
}

1 Answer 1

1

You need to loop through key sitelock of $get_data and in loop create new array contain custom data you want.

$arr = [];
foreach($get_data['sitelock'] as $key => $value){
    $arr[$key] = $value['plan_name'];
}

Check result in demo

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.