title: Is this an acceptable use of eval()?
body: <p>I'm trying to use an imploded string as an operator. And as a PHP novice, eval() is the only option that works, so far.</p>
  
  <p>I've read other questions/answers on <code>eval()</code>. In most cases, people were trying to allow actual code input by the user, which is NOT what I'm doing here.</p>
  
  <p>Here it is:</p>
  
  <pre><code>/*
   * Get user choices from a multiple-select customizer custom control.
   * Setting's choice values are the names of WordPress conditional tags.
   * Each choice set is given as 'key'=&gt;'label' NOT 'key'=&gt;'function'
   * so I'm limited to using strings here, e.g. is_front_page, is_singular.
   * The result will be a linear array, e.g. array( is_front_page, is_singular ).
   */
  $conditions = get_theme_mod( 'theme_setting' );
  
  /*
   * Here's where my trouble begins.
   * I need to append `()` to each array value using array_walk. */
  array_walk( $conditions, function(&amp;$value, $key) { $value = $value . '()'; });
  
  /*
   * Next I implode the array values to insert the or operator
   * So instead of "is_front_page, is_singular", I'd end up with
   * "is_front_page() || is_singular()"
   */
  $conditions = implode( ' || ', $conditions );
  
  /* The previous step is NOT usable, in my novice experience, hence eval() */
  eval( '$conditions =  ' . $conditions . ';');
  
  /* Eval makes the following usable */
  if( $conditions ) {
      // do stuff here
  }
  </code></pre>
  
  <p>I'm hoping this is acceptable because I'm not allowing code input from the user and my theme setting is static so I can't actually do something like <code>$conditions === true</code> as a workaround.</p>
  
  <p>Even if it is acceptable, please let me know if you have any advice on how to improve it.</p>