fork(3) download
  1. <?php
  2. $valid = array(1,2,3);
  3. $post = array('1','f','3', '3');
  4. if(is_array($post)){
  5. $post = array_unique($post);
  6. foreach($post as $key => $value){
  7. if(in_array($value, $valid)){
  8. $class = true;
  9. }else{
  10. unset($post[$key]);
  11. }
  12. }
  13. }
  14. if(isset($class)){
  15. echo 'class="class' . implode(' class', $post) . '"';
  16. }
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
class="class1 class3"