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 7176209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:27:39+00:00 2026-05-28T16:27:39+00:00

Ultimate Goal Is to make something like Magento offers – basically a logic builder,

  • 0

Ultimate Goal

Is to make something like Magento offers – basically a logic builder, and as shown by this post on Stackoverflow: jQuery (or any web tool) Nested Expression Builder So far I have made jQuery to build a tree and get the data that I want the builder to use, check, and set. Now I just need to parse the checks and add it into various places in a script I’m making – but I am unsure how to process it dynamically so that these checks can be performed, which will lead to some actions occurring/data being changed automatically.

Maybe we can call this dynamic expression processing?

Original Post

Forgive me, I know what I would like to do, but have little idea how to do it – so I’m looking for some inspiration. I have allowed a multidimensional array to be generated, and the array would contain certain ‘commands’ and logic functions, and when a condition is true it is executed.

In it’s most basic form, the array would contain a set of if statements, where if the statement were true, then would would proceed to the next array item and go down a level, if it were false, then you’d proceed to the next array item with no children (an unmarried sibling, i guess we could call it). Once there is nothing left to process, since nothing is true, then nothing would happen.

I’d imagine that maybe the best way to ‘feed’ the data in would be via XML – though would this be possible, I mean, to keep going deeper, else go down, essentially until there is a true condition?

Basically, the array takes the following form (though I not 100% sure I’ve written it correctly, but I think it looks right :s):

[0][0] => array('function' => 'if', 'check' => 'day', 'condition' => 'equals', 'value' => '3');
[0][1][0] => array('function' => 'set', 'name' => 'date_day', 'value' => 'wednesday');
[1][0] => array('function' => 'if', 'check' => 'day', 'condition' => 'equals', 'value' => '4');
[1][1][0] => array('function' => 'set', 'name' => 'date_day', 'value' => 'thursday');

So the above would be – if day=3, then set date_day as wednesday; else if day=4, then set date_day as thursday

Which I’d imagine would correspond to (though i have no idea if you can sub item):

<items>
    <item>
        <function>if</function>
        <check>day</check>
        <condition>equals</condition>
        <value>3</value>
        <item>
            <function>set</function>
            <name>date_day</name>
            <value>wednesday</value>
        </item>
    </item>
    <item>
        <function>if</function>
        <check>day</check>
        <condition>equals</condition>
        <value>4</value>
        <item>
            <function>set</function>
            <name>date_day</name>
            <value>thursday</value>
        </item>
    </item>
</items>

Which would basically make the following statements in a function of some sort:

function ($current_data){
  LOOP
    if(FUNCTION == "if"){
      if(CHECK CONDITION VALUE){
         **go to next item deeper in the chain**
      } else {
         **go to sibling item**
      }
    } else if(FUNCTION == "set"){
      define(NAME, VALUE);
    }
  ENDLOOP
}

I know the above can be done using the date() function, but this is a very basic example. Another example could involve check to see if the colour entered was red, and if it were, then set something based on this colour, else do something else if it were blue. Another could be to set the template to be for US visitors if the US flag was clicked on. The point is that it could basically fulfil any action and do a check and give a result – basically like programming – but where the function data is feed in by PHP or XML

I’m sure there must be something out there that can accomplish this, but I just have no idea were to start exactly, so any assistance would be great – and yes I know there could be some security concerns, but I plan on having checks in place checking that the checks, conditions, values, etc are safe (so this needs to be able to be factored in).

Many many thanks!

  • 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-28T16:27:40+00:00Added an answer on May 28, 2026 at 4:27 pm

    Okay JSON vs. XML aside, here’s how I would process that array…

    $array = xmldecode($xml);
    $resultFound = false;
    $i = 0;
    
    while(!$resultFound && $i < count($array)) {
        if (myFunction($array[$i]) {
           $resultFound = true;
        }
        $i++;
    }
    
    if (!$resultFound) {
        // error condition
    }
    
    function myFunction($array) {
        $function = $array[0]['function'];
    
        switch($function) {
            case 'if':
                $checkVariable = $array[0]['check'];
                $condition = $array[0]['condition'];
                $checkValue = $array[0]['value'];
                switch($checkVariable)
                   case 'day':
                       switch($condition) {
                           case 'equals':
                               if (GLOBAL_DAY == $checkValue) {
                                   return myFunction($array[1]);
                               } else {
                                   return false;
                               }
                               break;
                           case 'less than':
                               if (GLOBAL_DAY < $checkValue) {
                                   return myFunction($array[1]);
                               } else {
                                   return false;
                               }
                               break;
                       }
                   break;
                }
            break;    
            case 'set':
               $setVariable = $array[0]['name'];
               $setValue = $array[0]['value'];
               switch($setVariable) {
                    case 'date_day':
                         GLOBAL_DATE_DAY = $setValue;
                         return true;
                         break;
               }
            break;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my ultimate goal... to take this xml file.. <?xml version=1.0?> <Songs> <Song>
This is not a programming question per se, although the ultimate goal is to
Long time lurker, first time poster! Goal My ultimate goal is to make a
My ultimate goal is to be able to make use of additional mouse buttons
My ultimate goal is to have a menu that adds a class to the
My ultimate goal is to load controls as plugins, for use as DocumentContent in
My ultimate goal is to allow users to select a file from a dialog
I am trying to get my head around a LINQ issue. The ultimate goal
I'm working on a project where there is data visualization. My ultimate goal is
The ultimate goal is to add extra behavior to ListenableFuture s based on the

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.