Reymanx3x Posted October 19, 2010 Share Posted October 19, 2010 Hey guys! I have the following strange problem: Listing 1: echo $n; // Result is 20167 ! if($child->id == $n){ $image = array(); $image[] = '"' . $child->id . '"'; $image[] = '"' . $child->name . '"'; $image[] = '"' . $misc->clean_path($child->file) . '"'; $image[] = '"' . $child->file_name . '"'; $image[] = '"' . $child->file_type . '"'; $image[] = '"' . $path . '"'; $images[] = implode("\t", $image); } The if-statement is not true... so probably there's no $child->id with value 20167.... but watch this: Listing 2: if($child->id == 20167){ $image = array(); $image[] = '"' . $child->id . '"'; $image[] = '"' . $child->name . '"'; $image[] = '"' . $misc->clean_path($child->file) . '"'; $image[] = '"' . $child->file_name . '"'; $image[] = '"' . $child->file_type . '"'; $image[] = '"' . $path . '"'; $images[] = implode("\t", $image); } Now with the hard coded value 20167 the statement is true and gives one result.... Strange, isn't it? I placed the following three functions/test direct before the if-statement: var_dump($n); Result: NULL echo $n Result: 20167 echo "{$n}"; Result: I tested one function at a time. How can this happen? Thanks to all! :-) Quote Link to comment Share on other sites More sharing options...
Reymanx3x Posted October 19, 2010 Author Share Posted October 19, 2010 Probably you need the whole code of the function: function scanImages($id,$path,$picid) { global $server, $images, $misc; $childs = $server->children($id, "O.sort_order", "", 0); for ($i = 0; $i < count($childs->results); $i++) { $child = $server->object($childs->results[$i]); switch ($child->type) { case "183": if($child->id == $picid){ $image = array(); $image[] = '"' . $child->id . '"'; $image[] = '"' . $child->name . '"'; $image[] = '"' . $misc->clean_path($child->file) . '"'; $image[] = '"' . $child->file_name . '"'; $image[] = '"' . $child->file_type . '"'; $image[] = '"' . $path . '"'; $images[] = implode("\t", $image); } break; case "14": scanImages($child->id,$path."/".$child->name); break; default: }; }; } scanImages(181,"Bilder", 20167); Quote Link to comment Share on other sites More sharing options...
Reymanx3x Posted October 19, 2010 Author Share Posted October 19, 2010 Sorry, thread can be closed! The error was, that I forgot to forward the third argument of the function "scanImages" in the inner self-call: if($child->id == $picid){ $image = array(); $image[] = '"' . $child->id . '"'; $image[] = '"' . $child->name . '"'; $image[] = '"' . $misc->clean_path($child->file) . '"'; $image[] = '"' . $child->file_name . '"'; $image[] = '"' . $child->file_type . '"'; $image[] = '"' . $path . '"'; $images[] = implode("\t", $image); } break; case "14": scanImages($child->id,$path."/".$child->name); break; default: }; Thanks to everybody! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.