Reputation: 535
I'm trying to loop through this array to change the column value:
array
0 => null
1 =>
array
'condition' =>
array
'column' => string 'data' (length=12)
'operator' => string '=' (length=1)
'argvalue' => string '442' (length=3)
2 =>
array
'condition' =>
array
'column' => string 'start' (length=5)
'operator' => string '>=' (length=2)
'argvalue' => string '2013-11-21 00:00:00' (length=19)
3 =>
array
'condition' =>
array
'column' => string 'start' (length=5)
'operator' => string '<=' (length=2)
'argvalue' => string '2013-11-21 23:59:59' (length=19)
4 => null
Here's my code, whilst I can access $secondLevelIndex['column'] I don't seem to be able to change the value.
foreach ($created as $firstLevelIndex => $firstLevelArray) {
foreach ($firstLevelArray as $secondLevelIndex) {
//echo $secondLevelIndex['column'];
$created[$firstLevelIndex][$secondLevelIndex]['column'] = 100;
}
}
Any ideas would be appreciated.
Upvotes: 1
Views: 60
Reputation: 176
Something like this should work:
foreach ($created as $firstLevelIndex => $firstLevelArray) {
foreach ($firstLevelArray as $secondLevelIndex=>$value) {
//echo $secondLevelIndex['column'];
$created[$firstLevelIndex][$secondLevelIndex]['column'] = 100;
}
}
Upvotes: 1
Reputation: 1007
Try it.
foreach ($created as $firstLevelIndex => $firstLevelArray) {
foreach ($firstLevelArray as $secondLevelIndex => $secondLevelArray) {
//echo $secondLevelIndex['column'];
$created[$firstLevelIndex][$secondLevelIndex]['column'] = 100;
}
}
Upvotes: 2
Reputation: 4806
Try this
foreach ($created as $firstLevelIndex => $firstLevelArray) {
foreach ($firstLevelArray as $secondLevelIndex => $firstLevelArray) {
//echo $secondLevelIndex['column'];
$created[$firstLevelIndex][$secondLevelIndex]['column'] = 100;
}
}
Upvotes: 1