Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.48 KB | None | 0 0
  1.             pr($serviceTypes); //dump #1
  2.             pr($projects); //dump #2
  3.             foreach($projects as $key => $project) {
  4.                 foreach($serviceTypes as $serviceType){
  5.                     if(!in_array($serviceType, $project['ServiceType'])) {
  6.                             unset($projects[$key]);
  7.                             break;
  8.                     }
  9.                 }
  10.             }
  11.             pr($projects); //dump #3
  12.  
  13. //In this code, the entry with key 3 should be deleted. Instead, it is being modified (I commented where).
  14.  
  15. //DUMP #1 ($ServiceTypes)
  16. /*
  17. Array
  18. (
  19.     [0] => Shell
  20.     [1] => Renovation
  21. )
  22. */
  23.  
  24. //DUMP #2 ($Projects - before)
  25. Array
  26. (
  27.     [1] => Array
  28.         (
  29.             [Project] => Array
  30.                 (
  31.                     [id] => 30
  32.                     [name] => Pontal Sul
  33.                     [description] =>
  34.                     [owner] =>
  35.                     [location] => Colorado
  36.                     [sf] => 7
  37.                     [image] => uploads/projects/default.png
  38.                     [created] => 2010-11-02 16:50:04
  39.                     [modified] => 2010-11-02 16:50:04
  40.                 )
  41.  
  42.             [ProjectType] => Array
  43.                 (
  44.                     [0] => Office
  45.                     [1] => Residential/Multi-Family
  46.                     [2] => Retail
  47.                     [3] => Healthcare
  48.                     [4] => Education
  49.                     [5] => Hospitality
  50.                     [6] => Spiritual
  51.                     [7] => LEED/Sustainable
  52.                 )
  53.  
  54.             [ServiceType] => Array
  55.                 (
  56.                     [0] => Shell
  57.                     [1] => Renovation
  58.                     [2] => Service
  59.                 )
  60.  
  61.         )
  62.  
  63.     [3] => Array
  64.         (
  65.             [Project] => Array
  66.                 (
  67.                     [id] => 32
  68.                     [name] => Pontal Oeste
  69.                     [description] =>
  70.                     [owner] =>
  71.                     [location] => New Mexico
  72.                     [sf] => 4
  73.                     [image] => uploads/projects/default.png
  74.                     [created] => 2010-11-02 16:51:33
  75.                     [modified] => 2010-11-02 16:51:33
  76.                 )
  77.  
  78.             [ProjectType] => Array
  79.                 (
  80.                     [0] => Office
  81.                     [1] => Education
  82.                 )
  83.  
  84.             [ServiceType] => Array
  85.                 (
  86.                     [0] => Tenant Improvement
  87.                 )
  88.  
  89.         )
  90.  
  91. )
  92.  
  93. //DUMP #3 ($projects - after) ENTRY NUMBER 3 WAS NOT DELETED. INSTEAD, IT WAS MODIFIED!
  94. Array
  95. (
  96.     [1] => Array
  97.         (
  98.             [Project] => Array
  99.                 (
  100.                     [id] => 30
  101.                     [name] => Pontal Sul
  102.                     [description] =>
  103.                     [owner] =>
  104.                     [location] => Colorado
  105.                     [sf] => 7
  106.                     [image] => uploads/projects/default.png
  107.                     [created] => 2010-11-02 16:50:04
  108.                     [modified] => 2010-11-02 16:50:04
  109.                 )
  110.  
  111.             [ProjectType] => Array
  112.                 (
  113.                     [0] => Office
  114.                     [1] => Residential/Multi-Family
  115.                     [2] => Retail
  116.                     [3] => Healthcare
  117.                     [4] => Education
  118.                     [5] => Hospitality
  119.                     [6] => Spiritual
  120.                     [7] => LEED/Sustainable
  121.                 )
  122.  
  123.             [ServiceType] => Array
  124.                 (
  125.                     [0] => Shell
  126.                     [1] => Renovation
  127.                     [2] => Service
  128.                 )
  129.  
  130.         )
  131.  
  132.     [3] => Array
  133.         (
  134.             [Project] => Array
  135.                 (
  136.                     [id] => 32
  137.                     [name] => Pontal Oeste
  138.                     [description] =>
  139.                     [owner] =>
  140.                     [location] => New Mexico
  141.                     [sf] => 4
  142.                     [image] => uploads/projects/default.png
  143.                     [created] => 2010-11-02 16:51:33
  144.                     [modified] => 2010-11-02 16:51:33
  145.                 )
  146.  
  147.             [ProjectType] => Array
  148.                 (
  149.                     [0] => Office
  150.                     [1] => Education
  151.                 )
  152.  
  153.             [ServiceType] => Array
  154.                 (
  155.                     [0] => Renovation //HERE. AS YOU CAN SEE, THAT IS DIFFERENT IN THE 2ND DUMP
  156.                 )
  157.  
  158.         )
  159.  
  160. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement