Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pr($serviceTypes); //dump #1
- pr($projects); //dump #2
- foreach($projects as $key => $project) {
- foreach($serviceTypes as $serviceType){
- if(!in_array($serviceType, $project['ServiceType'])) {
- unset($projects[$key]);
- break;
- }
- }
- }
- pr($projects); //dump #3
- //In this code, the entry with key 3 should be deleted. Instead, it is being modified (I commented where).
- //DUMP #1 ($ServiceTypes)
- Array
- (
- [0] => Shell
- [1] => Renovation
- )
- //DUMP #2 ($Projects - before)
- Array
- (
- [1] => Array
- (
- [Project] => Array
- (
- [id] => 30
- [name] => Pontal Sul
- [description] =>
- [owner] =>
- [location] => Colorado
- [sf] => 7
- [image] => uploads/projects/default.png
- [created] => 2010-11-02 16:50:04
- [modified] => 2010-11-02 16:50:04
- )
- [ProjectType] => Array
- (
- [0] => Office
- [1] => Residential/Multi-Family
- [2] => Retail
- [3] => Healthcare
- [4] => Education
- [5] => Hospitality
- [6] => Spiritual
- [7] => LEED/Sustainable
- )
- [ServiceType] => Array
- (
- [0] => Shell
- [1] => Renovation
- [2] => Service
- )
- )
- [3] => Array
- (
- [Project] => Array
- (
- [id] => 32
- [name] => Pontal Oeste
- [description] =>
- [owner] =>
- [location] => New Mexico
- [sf] => 4
- [image] => uploads/projects/default.png
- [created] => 2010-11-02 16:51:33
- [modified] => 2010-11-02 16:51:33
- )
- [ProjectType] => Array
- (
- [0] => Office
- [1] => Education
- )
- [ServiceType] => Array
- (
- [0] => Tenant Improvement
- )
- )
- )
- //DUMP #3 ($projects - after) ENTRY NUMBER 3 WAS NOT DELETED. INSTEAD, IT WAS MODIFIED!
- Array
- (
- [1] => Array
- (
- [Project] => Array
- (
- [id] => 30
- [name] => Pontal Sul
- [description] =>
- [owner] =>
- [location] => Colorado
- [sf] => 7
- [image] => uploads/projects/default.png
- [created] => 2010-11-02 16:50:04
- [modified] => 2010-11-02 16:50:04
- )
- [ProjectType] => Array
- (
- [0] => Office
- [1] => Residential/Multi-Family
- [2] => Retail
- [3] => Healthcare
- [4] => Education
- [5] => Hospitality
- [6] => Spiritual
- [7] => LEED/Sustainable
- )
- [ServiceType] => Array
- (
- [0] => Shell
- [1] => Renovation
- [2] => Service
- )
- )
- [3] => Array
- (
- [Project] => Array
- (
- [id] => 32
- [name] => Pontal Oeste
- [description] =>
- [owner] =>
- [location] => New Mexico
- [sf] => 4
- [image] => uploads/projects/default.png
- [created] => 2010-11-02 16:51:33
- [modified] => 2010-11-02 16:51:33
- )
- [ProjectType] => Array
- (
- [0] => Office
- [1] => Education
- )
- [ServiceType] => Array
- (
- [0] => Renovation //HERE. AS YOU CAN SEE, THAT IS DIFFERENT IN THE 2ND DUMP
- )
- )
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement