Re: Breaking up data efficiently

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux