troubleshooting Question

PHP Loop condition not hitting

Avatar of Gary
GaryFlag for Ireland asked on
PHP
7 Comments1 Solution194 ViewsLast Modified:
Can anyone see something wrong with the below code.
The only conditions met are internet, health (one condition from 2 it should hit) and parking (but only 1 condition from 4)
I know they are not being hit because they just show up in the main list (the else...)


foreach($hotel->PropertyAmenities[0] as $amenities) {
	$amenity=strtolower(trim($amenities->amenity));
	if (strpos($amenity,"number of buildings") ===false && strpos($amenity,"number of rooms")===false && strpos($amenity,"number of floors")===false) {
		if(strpos($amenity,"internet")){
			$internet.='<li>'.$amenities->amenity.'</li>'."\n";
		}
		elseif(strpos($amenity,"parking")){
			$parking.='<li>'.$amenities->amenity.'</li>'."\n";
		}
		elseif(strpos($amenity,"billiards") || strpos($amenity,"pool table") || strpos($amenity,"fitness") || strpos($amenity,"gym") || strpos($amenity,"health")){
			$activities.='<li>'.$amenities->amenity.'</li>'."\n";
		}
		elseif(strpos($amenity,"sauna") || strpos($amenity,"steam room") || strpos($amenity,"swimming") || strpos($amenity,"spa ") || strpos($amenity,"massage")){
			$activities.='<li>'.$amenities->amenity.'</li>'."\n";
		}
		else{
			echo '<li>'.$amenities->amenity.'</li>'."\n";
		}
	}
}

This is from an xml file, sample here
<PropertyAmenities size="51"><PropertyAmenity><amenityId>3184708</amenityId><amenity>24-hour front desk </amenity></PropertyAmenity><PropertyAmenity><amenityId>3871936</amenityId><amenity>Accessible bathroom </amenity></PropertyAmenity><PropertyAmenity><amenityId>1125113</amenityId><amenity>Air-conditioned public areas                    </amenity></PropertyAmenity><PropertyAmenity><amenityId>3184702</amenityId><amenity>Audio-visual equipment </amenity></PropertyAmenity><PropertyAmenity><amenityId>7182368</amenityId><amenity>Babysitting or child care </amenity></PropertyAmenity>
ASKER CERTIFIED SOLUTION
Robert Schutt
Software Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros