karthikanov24 Posted November 2, 2009 Share Posted November 2, 2009 hi $child = array_merge($child, getChildCategories($categories, $catId)); In the above line of code,the value(return value) of the function getChildCategories() is an array.... how to check(what debugging code is used) whether there is any value or in that function(or array) or it is null....? thanks karthikanov24 Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted November 2, 2009 Share Posted November 2, 2009 if(count($array) >= 1) echo "array has result"; else echo "error"; Quote Link to comment Share on other sites More sharing options...
karthikanov24 Posted November 2, 2009 Author Share Posted November 2, 2009 hi In the above posting,there is no variable like $array .There is only function getChildCategories() having array..... so could you give the code using that function to check the value in it...please.. thanks karthikanov24 Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted November 2, 2009 Share Posted November 2, 2009 $child = array_merge($child, getChildCategories($categories, $catId)); if(!is_array($child)) echo "error"; else if (count($child ) >= 1) echo "array has result"; else echo "error"; Quote Link to comment Share on other sites More sharing options...
karthikanov24 Posted November 2, 2009 Author Share Posted November 2, 2009 hi Is this correct...? if(count(getChildCategories($categories,$catId))>0) echo "have values"; else echo "empty"; Actually i want to check the value of getChildCategories() alone...and not others.. Please could you help me.... thanks karthikanov24 Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted November 2, 2009 Share Posted November 2, 2009 if(count(getChildCategories($categories,$catId))>0) echo "have values"; else echo "empty"; if you miss out the curly brackets you must use the same line Quote Link to comment Share on other sites More sharing options...
cags Posted November 2, 2009 Share Posted November 2, 2009 It being on the same line or not will make absolutely no difference. I would however recommend using curly brackets even if you only have a single lines, it helps limit errors creeping into code. Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted November 2, 2009 Share Posted November 2, 2009 It being on the same line or not will make absolutely no difference. I would however recommend using curly brackets even if you only have a single lines, it helps limit errors creeping into code. its only 1 line after no brackets that gets executed am i right ? Quote Link to comment Share on other sites More sharing options...
cags Posted November 2, 2009 Share Posted November 2, 2009 Without curly braces only the first 'line' of code following the statement will be done as part of the statement. But whitespace doesn't make the slightest bit of difference. // this if(true) echo "True"; else echo "False"; // is exactly the same as this if(true) echo "True"; else echo "False"; I would always recommend a variation of this as the 'correct' way of doing it. Otherwise you can introduce problems when you complicate things. if(true) { echo "True"; } else { echo "False"; } 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.