Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
54
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. Array
  17. (
  18.     [0] => Shell
  19.     [1] => Renovation
  20. )
  21.  
  22. //DUMP #2 ($Projects - before)
  23. Array
  24. (
  25.     [1] => Array
  26.         (
  27.             [Project] => Array
  28.                 (
  29.                     [id] => 30
  30.                     [name] => Pontal Sul
  31.                     [description] =>
  32.                     [owner] =>
  33.                     [location] => Colorado
  34.                     [sf] => 7
  35.                     [image] => uploads/projects/default.png
  36.                     [created] => 2010-11-02 16:50:04
  37.                     [modified] => 2010-11-02 16:50:04
  38.                 )
  39.  
  40.             [ProjectType] => Array
  41.                 (
  42.                     [0] => Office
  43.                     [1] => Residential/Multi-Family
  44.                     [2] => Retail
  45.                     [3] => Healthcare
  46.                     [4] => Education
  47.                     [5] => Hospitality
  48.                     [6] => Spiritual
  49.                     [7] => LEED/Sustainable
  50.                 )
  51.  
  52.             [ServiceType] => Array
  53.                 (
  54.                     [0] => Shell
  55.                     [1] => Renovation
  56.                     [2] => Service
  57.                 )
  58.  
  59.         )
  60.  
  61.     [3] => Array
  62.         (
  63.             [Project] => Array
  64.                 (
  65.                     [id] => 32
  66.                     [name] => Pontal Oeste
  67.                     [description] =>
  68.                     [owner] =>
  69.                     [location] => New Mexico
  70.                     [sf] => 4
  71.                     [image] => uploads/projects/default.png
  72.                     [created] => 2010-11-02 16:51:33
  73.                     [modified] => 2010-11-02 16:51:33
  74.                 )
  75.  
  76.             [ProjectType] => Array
  77.                 (
  78.                     [0] => Office
  79.                     [1] => Education
  80.                 )
  81.  
  82.             [ServiceType] => Array
  83.                 (
  84.                     [0] => Tenant Improvement
  85.                 )
  86.  
  87.         )
  88.  
  89. )
  90.  
  91. //DUMP #3 ($projects - after) ENTRY NUMBER 3 WAS NOT DELETED. INSTEAD, IT WAS MODIFIED!
  92. Array
  93. (
  94.     [1] => Array
  95.         (
  96.             [Project] => Array
  97.                 (
  98.                     [id] => 30
  99.                     [name] => Pontal Sul
  100.                     [description] =>
  101.                     [owner] =>
  102.                     [location] => Colorado
  103.                     [sf] => 7
  104.                     [image] => uploads/projects/default.png
  105.                     [created] => 2010-11-02 16:50:04
  106.                     [modified] => 2010-11-02 16:50:04
  107.                 )
  108.  
  109.             [ProjectType] => Array
  110.                 (
  111.                     [0] => Office
  112.                     [1] => Residential/Multi-Family
  113.                     [2] => Retail
  114.                     [3] => Healthcare
  115.                     [4] => Education
  116.                     [5] => Hospitality
  117.                     [6] => Spiritual
  118.                     [7] => LEED/Sustainable
  119.                 )
  120.  
  121.             [ServiceType] => Array
  122.                 (
  123.                     [0] => Shell
  124.                     [1] => Renovation
  125.                     [2] => Service
  126.                 )
  127.  
  128.         )
  129.  
  130.     [3] => Array
  131.         (
  132.             [Project] => Array
  133.                 (
  134.                     [id] => 32
  135.                     [name] => Pontal Oeste
  136.                     [description] =>
  137.                     [owner] =>
  138.                     [location] => New Mexico
  139.                     [sf] => 4
  140.                     [image] => uploads/projects/default.png
  141.                     [created] => 2010-11-02 16:51:33
  142.                     [modified] => 2010-11-02 16:51:33
  143.                 )
  144.  
  145.             [ProjectType] => Array
  146.                 (
  147.                     [0] => Office
  148.                     [1] => Education
  149.                 )
  150.  
  151.             [ServiceType] => Array
  152.                 (
  153.                     [0] => Renovation //HERE. AS YOU CAN SEE, THAT IS DIFFERENT IN THE 2ND DUMP
  154.                 )
  155.  
  156.         )
  157.  
  158. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement