RE: [PHP] HELP UNIX vs Windows
| From: | Ford, Mike [LSS] | Date: | Thu, 07 Mar 2002 13:30:12 +0000 |
| Subject: | RE: [PHP] HELP UNIX vs Windows | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-87617@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Christopher J. Crane [mailto:ccrane@inxdesign.com]
> Sent: 07 March 2002 02:26
>
> The problem is that on the windows platform all information
> is returned. On
> the linux platform the "$Details" variable is not populated.
> The nothing
> changes...so what could it be. The only thing I can think of
> is that maybe
> the version of php is different on the linux server.
Sounds like a good bet, since the online manual entry for strtok says the following:
"The behavior when an empty part was found changed with PHP 4.1.0. The old behavior returned an
empty string, while the new, correct, behavior simply skips the part of the string..."
So, if you have a line like this:
cat|sku|name||9.99|image1|image2|yes|8.99|Massive reduction on widgets!|
version prior to 4.1.0 would return 10 values (including a null 4th value for SubCategory), whereas
from 4.1.0 onward you would get only the 9 non-null values.
Thus, if you can legitimately have null values for any of your fields, using the split/explode route
as previously suggested is definitely the way to go: explode('|', $cartFile[$i]) will
return an array of the field values, including nulls, regardless of PHP version; you can then work
with the array elements, or assign them to scalar variables using the list() construct.
NOTE: explode('|', '|a|b|') will actually return an array with 4 elements, as
explode "sees" empty fields before the first delimiter and after the last -- you can, of
course, simply ignore these, but you need to be aware that they're there if this is how your
lines are formatted.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211