Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- array(4) {
- [0]=>
- array(2) {
- ["id"]=>
- string(4) "id-1"
- ["articles"]=>
- array(2) {
- [0]=>
- array(1) {
- ["data"]=>
- array(6) {
- ["art"]=>
- string(6) "108108"
- ["type"]=>
- string(0) ""
- ["pos"]=>
- string(3) "125"
- ["kleur"]=>
- string(4) "3750"
- ["height"]=>
- string(3) "179"
- ["foto"]=>
- string(2) "01"
- }
- }
- [1]=>
- array(1) {
- ["data"]=>
- array(6) {
- ["art"]=>
- string(0) ""
- ["type"]=>
- string(0) ""
- ["pos"]=>
- string(3) "163"
- ["kleur"]=>
- string(0) ""
- ["height"]=>
- string(0) ""
- ["foto"]=>
- string(0) ""
- }
- }
- }
- }
- [2]=>
- array(2) {
- ["id"]=>
- string(7) "ui-id-2"
- ["articles"]=>
- array(2) {
- [0]=>
- array(1) {
- ["data"]=>
- array(6) {
- ["art"]=>
- string(0) ""
- ["type"]=>
- string(0) ""
- ["pos"]=>
- string(3) "944"
- ["kleur"]=>
- string(0) ""
- ["height"]=>
- string(0) ""
- ["foto"]=>
- string(0) ""
- }
- }
- [1]=>
- array(1) {
- ["data"]=>
- array(6) {
- ["art"]=>
- string(0) ""
- ["type"]=>
- string(0) ""
- ["pos"]=>
- string(3) "586"
- ["kleur"]=>
- string(0) ""
- ["height"]=>
- string(0) ""
- ["foto"]=>
- string(0) ""
- }
- }
- }
- }
- }
- foreach($data as $key => $value) {
- if($value['id'] === "id-1") {
- foreach($value as $tweek => $tweev) {
- foreach($tweev as $driek => $driev) {
- foreach($driev as $vierk => $vierv) {
- if($vierv['pos'] === "163") {
- // This is the right article! I think...
- echo $vierv['pos'] . "<br />"; // shows 163!
- foreach($vierv as $vijfk => $vijfv) {
- // What to do?!?!
- }
- }
- }
- }
- }
- }
- }
- <?php
- $a1=array("a"=>"red","pos"=>"364");
- $a2=array($a1,"1"=>"blue","2"=>"yellow");//one array inside another to simulate your multi depth array
- array_walk_recursive($a2,"myfunction");//use array_recursive
- function myfunction($value,$key)
- {
- if ($key == 'pos' && $value == '364') { //set your condition here
- echo "change your key or value here";
- }
- }
- ?>
- arr = array(
- 0=>array(
- 'id'=>"id-1",
- 'articles'=> array(
- 0=>array(
- 'data'=> array(
- 'art'=> "108108"
- 'type'=> ""
- 'pos'=> "125"
- 'kleur'=> "3750"
- 'height'=> "179"
- 'foto'=> "01"
- ),
- ),
- 1=> array(
- 'data'=> array(
- 'art'=> ""
- 'type'=> ""
- 'pos'=> "163"
- 'kleur'=> ""
- 'height'=> ""
- 'foto'=> ""
- ),
- ),
- ),
- ),
- 2=> array(
- 'id'=>"ui-id-2"
- 'articles'=> array(
- 0=> array(
- 'data'=> array(
- 'art'=> ""
- 'type'=> ""
- 'pos'=> "944"
- 'kleur'=> ""
- 'height'=> ""
- 'foto'=> ""
- ),
- ),
- 1=> array(
- 'data'=> array(
- 'art'=> ""
- 'type'=> ""
- 'pos'=> "586"
- 'kleur'=> ""
- 'height'=> ""
- 'foto'=> ""
- ),
- ),
- ),
- ),
- );
- foreach ($arr as $key=>value)
- if ($value['id'] == 'id-1')
- foreach($value as $key2=>$value2)
- if ($value2['pos'] == 163)
- $value2['art'] = $newArtValue;
- $arr = array(
- 'id-1'=>array(
- 'articles'=> array(
- 125=>array(
- 'art'=> "108108"
- 'type'=> ""
- 'kleur'=> "3750"
- 'height'=> "179"
- 'foto'=> "01"
- ),
- 163=> array(
- 'art'=> ""
- 'type'=> ""
- 'kleur'=> ""
- 'height'=> ""
- 'foto'=> ""
- ),
- ),
- ),
- 'ui-id-2'=> array(
- 'articles'=> array(
- 944=> array(
- 'art'=> ""
- 'type'=> ""
- 'kleur'=> ""
- 'height'=> ""
- 'foto'=> ""
- ),
- 586=> array(
- 'art'=> ""
- 'type'=> ""
- 'kleur'=> ""
- 'height'=> ""
- 'foto'=> ""
- ),
- ),
- ),
- );
- $arr['id-1'][163]['art'] = $newArtValue;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement