I have a big problem with Strings, have tried to find the error for hours, without any result!
I. Script that works fine:
----------------------------
PHP-Code:
Code: Select all
<?php
$array[3] = '76534 Baden-Baden';
print gettype($array[3]).'<br>';
$strPlz = substr($array[3],0,4);
$strOrt = strstr($array[3],' ');
print "PLZ=".$strPlz."<br>";
print "Ort=".$strOrt;
?>Remarks: PLZ is the German ZIP-Code for a city. Ort ist the city name.
=> Output:
string
PLZ=7653
Ort= Baden-Baden
=>Great! PLZ and Ort have sucessfully been parsed out of the string.
II. Script which doesn't work:
----------------------------------
PHP-Code:
Code: Select all
<?php
...
writeDataIntoDatabase($output_array_unique);
...
function writeDataIntoDatabase($array)
{
global $idLink;
print gettype($array[3]).'<br>';
$strPlz = substr($array[3],0,4);
$strOrt = strstr($array[3],' ');
print "PLZ=".$strPlz."<br>";
print "Ort=".$strOrt;
}
?>=> Output:
string
PLZ=
Ort= 76534 Baden-Baden
==> HELP! Why doesn't the same thing happen like in script I? I don't understand this at all!!!
==> Why is $strPlz empty and $strOrt not?
Thanks for your help,
visionmaster