In Germany we have street names and house numbers. I work with a database where both is stored in a single column (for example "Arnoldstraße 12") and I want to seperate both into single variables.
I have this code:
$street= $row[2]; //This row is from an array with values of the database. The other rows are submitted perfectly.
preg_match('/([^\d]+)(\d+.*)/', $street, $matches);
$street_new = trim($matches[1]);
$house_number= trim($matches[2]);
while ($row = $jobDB->fetchArray($result)) {
$this->setReturnValue('strasse', $street_new);
$this->setReturnValue('hausnummer', $house_number);
return;
}
After that, I use a JS-Code to get that (and more values) into a form on a website. The other values get there without problems, just the street name and the house number are missing.
Here's the JS-code:
var auto_complete = function() {
var kontonr = jr_get_value('tb_kundennummer');
jr_execute_dialog_function('autoComplete', {kontonummer: kontonr}, mySuccessCallback);
}
var mySuccessCallback = function(returnObject) {
jr_set_value('tb_kunde_strasse', returnObject.result.street_new);
jr_set_value('tb_kunde_hausnummer', returnObject.result.house_number);
}
What am I doing wrong?
Thank you in advance: :)
Ok I found a solution. After adding the code into the while-loop it worked perfectly:
while ($row = $jobDB->fetchArray($result)) {
$street= $row[2];
preg_match('/([^\d]+)(\d+.*)/', $street, $matches);
$street= trim($matches[1]);
$house_number= trim($matches[2]);
$this->setReturnValue('strasse', $street);
$this->setReturnValue('hausnummer', $house_number);
return;
}
I'm not much of a developer, but maybe it was because the $row only works if called after the fetchArray. But I'm not sure.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.