PHP : Function - Return 2 variables (Boolean + $variable) -


issue resolved : here solution :

function testcoreq()     {         $coreqtest = makecoreq();          if(empty($coreqtest))         {             return array(true);             break;         }         else         {             foreach ($coreqtest $ctest)             {                 if($ctest['value'] == "true")                 {                     return array(true);                     break;                 }                 else                 {                     return array(false,$ctest['coreqid']);                 }             }         }      }  if(testcoreq()[0]) {   //do } else {   return testcoreq()[1] }    

i'm doing school project , hit kind of bump.

i created function , want either return "true" (boolean) or "false" (boolean) + variable.

i searched net quite bit wan't able find simple way .

is there way this ? //thanks

the function working when returning variable - assuming function returning "true" when want return false + value :

else                 {                     return $ctest['coreqid'];                     return false;                 } 

here code :

function testcoreq()     {         $coreqtest = makecoreq();          if(empty($coreqtest))         {             return true;             break;         }         else         {             foreach ($coreqtest $ctest)             {                 if($ctest['value'] == "true")                 {                     return true;                     break;                 }                 else                 {                     return $ctest['coreqid'];                 }             }         }      } 

i using this:

if (testcoreq()) {  // } else {  // return variable } 

but if first statement false , returning variable - assuming function true.

you can try return -1 on true , other false decrease amount of returning values. next option return array of values. other option pass reference variable in function.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -