1

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.

3 Answers 3

2

Try it.

foreach ($created as $firstLevelIndex => $firstLevelArray) {
  foreach ($firstLevelArray as $secondLevelIndex => $secondLevelArray) {
    //echo $secondLevelIndex['column'];
    $created[$firstLevelIndex][$secondLevelIndex]['column'] = 100;
  }
}
Sign up to request clarification or add additional context in comments.

Comments

1

Try this

foreach ($created as $firstLevelIndex => $firstLevelArray) {
  foreach ($firstLevelArray as $secondLevelIndex => $firstLevelArray) {
    //echo $secondLevelIndex['column'];
    $created[$firstLevelIndex][$secondLevelIndex]['column'] = 100;
  }
}

Comments

1

Something like this should work:

foreach ($created as $firstLevelIndex => $firstLevelArray) {
  foreach ($firstLevelArray as $secondLevelIndex=>$value) {
    //echo $secondLevelIndex['column'];
    $created[$firstLevelIndex][$secondLevelIndex]['column'] = 100;
  }
}

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.