Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/179979-checking-the-array/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/179979-checking-the-array/#findComment-949449
Share on other sites

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 ?

Link to comment
https://forums.phpfreaks.com/topic/179979-checking-the-array/#findComment-949479
Share on other sites

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";
}

Link to comment
https://forums.phpfreaks.com/topic/179979-checking-the-array/#findComment-949498
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.