-1

I have the following code :

echo $gibs=Db::getResult($sql,$query);
  print_r($gibs);
  count($gibs);
  if($gibid!='' && count($gibs)<=0){
   $gibs=array(
    'gibid'=>$gibid,
    'userid'=>$userid,
    'isowner'=>false
   );

  }

Resulting output :

ArrayArray ( ) 

why count($gibs) not returning any thing.

thats why the flow don't going in if condition.

7
  • 1
    count() returns a value. In your case count($gibs); does nothing. Commented Dec 29, 2010 at 9:26
  • what is count($gibs) exactly returning? please vardump or print_r it! Commented Dec 29, 2010 at 9:27
  • ... Maybe because Db::getResult($sql,$query); is returning an empty result set? Commented Dec 29, 2010 at 9:27
  • Is your SQL statement actually returning any rows? Commented Dec 29, 2010 at 9:27
  • var_dump(count($gibs));//returns int(0) print_r(count($gibs));//returns 0 Commented Dec 29, 2010 at 9:31

1 Answer 1

0

To see the output of count($gibs); you should assign the function to some variable, or print it:

print_r(count($gibs));

In your case, it's value will be 0, because $gibs array is empty (it is seen out of the print_r output).

If condition might not work, because $gibid == 0

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.