|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-04-05 10:51 UTC] xsmokex at chello dot at
Description:
------------
count just stops returning any values inside my function
outside it returns the value it should quite dissapointing bug :/
Reproduce code:
---------------
$idxsplit = "kunden___Kunden_Nr,kunden___Zuname";
$idx = explode(",",$idxsplit); //Index Felder
$idxcnt = count($idx);
echo $idxcnt;
//Aktives Feld Index Feld?
function isidx($obj) {
echo $obj;
$retval = 0;
if ($obj != "") {
echo "obj";
echo $idxcnt;
echo "test";
for ($i = 0; $i < $idxcnt; $i++) {
echo $idx[$i];
if ($idx[$i] == $obj) {
$retval = 1;
break;
}
}
}
echo $idxcnt;
echo "ende".$retval;
return $retval;
}
//Erster Satz
if ($kunden___speichern == "mer") {
if (isidx($kunden___AKTFLD)) { //kunden___Kunden_Nr/kunden___Zuname
Expected result:
----------------
well runing isidx() with $kunden___AKTFLD(value:kunden___Kunden_Nr or kunden___Zuname ....)
returning true/false if the current selected field is a indexed field
Actual result:
--------------
the echo returnings:
2kunden___Kunden_Nrobjtestende0
Broken down:
outside function:
2: echo $idxcnt;
inside function:
kunden___Kunden: echo $obj;
obj: echo "obj";
: echo $idxcnt; //no value returned
test echo "test";
: echo $idx[$i]; //dont get into due no value from $idxcnt
: echo $idxcnt; //no value returned
ende0 echo "ende".$retval;
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 24 04:00:01 2025 UTC |
sorry didnt know u need it for tests in that way here you have the requested sample (no additional things needed just run it) SCRIPT: <?php $idxsplit = "kunden___Kunden_Nr,kunden___Zuname"; $idx = explode(",",$idxsplit); //Index Felder $idxcnt = count($idx); echo $idxcnt; //Aktives Feld Index Feld? function isidx($obj) { echo $obj; $retval = 0; if ($obj != "") { echo "obj"; echo $idxcnt; echo "test"; for ($i = 0; $i < $idxcnt; $i++) { echo $idx[$i]; if ($idx[$i] == $obj) { $retval = 1; break; } } } echo $idxcnt; echo "ende".$retval; return $retval; } //the Test (should normally return echo "index field";) if (!isidx("kunden___Kunden_Nr")) { //not a indexfield echo "not a index field"; } else { echo "index field"; } ?>