2

I am pretty new with associative arrays. Just trying to create a dynamic associative array.

Current Array -

stdClass Object
(
    [354] => Array
        (
        )

    [355] => Array
        (
        )

)

Trying to get desired output

stdClass Object
(
    [354] => Array
        (
            [activity_desc] = "description"
        )

    [355] => Array
        (
           [activity_desc] = "description"
        )

)

wrote an sql to check key (354, 355) and return description.

How to I store key and value under 344 & 355?

Current code:

foreach ($report as $key=>$value) 
{
    $where = 'item_id = ' . $key . '';		
	$query = $db->prepare('SELECT activity_desc FROM program WHERE '. $where);
	$query->execute();
	$test = $query->fetch(PDO::FETCH_OBJ);
}

this is my sql return query for 354. 355 will be roughly the same.

stdClass Object ( [activity_desc] => <p>Send Activity</p>

Thanks in advance

Fugz

1 Answer 1

1

wow it was that simple........

$report->$key = $test;

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.