php - Altering array data around different loops
Get the solution ↓↓↓Solution:
Sounds like you want to pass array BY REFERENCE.
This means you are treating the array NOT like a typical array (a copy) but like a pointer to the$data
array.
It is similar to how you might use an object (which is not a copy but an instance itself).
You can implement this with:
foreach($data as &$item){
$item['new var'] ='my new data';
}
foreach($data as $item){
var_dump($item['new key']);//print 'my new data'
}
hope that helps
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: trying to access array offset on value of type bool in
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.