Re: Breaking up data efficiently

From: Date: Tue, 28 Jun 2005 04:53:41 +0000
Subject: Re: Breaking up data efficiently
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-217737@lists.php.net to get a copy of this message
I agree, your implementation is efficient. It does depend on the data being entirely proper, however. If you can not be entirely sure (and you should rarely be), i might add a suggestion that increases code length, but decreases the chance of problems: You might consider creating a function to validate the location as well as list() = explode() it. $locations = explode('|', $booking->booking_flight_details); foreach ($locations as $location) $list[] = split_location($location); Create the function split_location to return the associative array or, if it is invalid, throws an exception. If PHP4, replace the exception with similar error handling.

« previous php.general (#217737) next »