Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5932203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:48:07+00:00 2026-05-22T14:48:07+00:00

i have an array contain value like Array ( [0] = true [1] =

  • 0

i have an array contain value like

Array
(
    [0] = true
    [1] = OR
    [2] = true
    [3] = AND
    [4] = false
    [5] = AND
    [6] = true
)

i want to create truth table in php like e.g

true OR true = result1
result1 AND false = result2
result2 AND true = result3

i’m stupid and not b able to create yet. 🙁

here is my code

foreach( $arrValue as $val  )
{
     if(!empty($val))
     {
    if($val=='true')
        $p = true;
    elseif($val=='false')
        $p = false;

    if(isset($p))
    {
            if(isset($result))
        {
             if($val=='AND')
             $result = $result AND $p;                      
        elseif($val=='OR')
             $$result = $result or $p;              

        }
       else
        $result = $p;
    }           
    }
}

please help this stupid boy to get results.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:48:08+00:00Added an answer on May 22, 2026 at 2:48 pm

    This is what i want.

    //( [0] => true [1] => OR [2] => true [3] => AND [4] => false [5] => AND [6] => true)
    
    function boolstr($val) {
        if($val=='true')
            return true;
        elseif($val=='false')
            return false;
    }
    
    
    function row_operator($arrValue){
        $i=-2; $j=-1;
        foreach( $arrValue as $val  )
        {
            if($i+3 > count($arrValue)) break;
            $boolste = boolstr($arrValue[$i+2]);
            if(isset($res))
            {
                if($arrValue[$j+2]=='AND')
                    $res = $res && $boolste;
                elseif($arrValue[$j+2]=='OR')           
                    $res = $res || $boolste;            
    
                if($res==true)
                    $a='true';
                else $a= 'false';
                    $j += 2;
            }
            else
                $res = $boolste;
    
            $i += 2;
        }
        return $res;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of strings that contain html <object> 's like so: $str
I have a SQL table with column which contain string like 'type|type1|type2|type3|type4'. I need
Right now, I have this code where $obj_arr maybe contain array and an object.
I have some input fields like below: <input type=text name=date_1 class=dataList value=2009-12-30 /> <input
So I have a array of records and I would like to group by
I have an array that can contain any number of elements. Each element contains
I want to create a pointer to an array of pointers (with 10 pointers
I have an array that could contain zero values. $array = array(3=> 1000, 5=>
I would like to sort an array by the value in its first index,
I have an array that contains the RGB colour values for each pixel in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.