Paste Search Dynamic
Recent pastes
substr strpos data
  1. <?php
  2. $data = "022";    
  3. $arr = explode("-", $data, 2);
  4. $first = $arr[0];
  5.  
  6. if (preg_match('~[0-9]+~', $first)) {
  7.     echo $data;
  8. }else
  9. {
  10.        
  11. $whatIWant = substr($data, strpos($data, "-") + 1);
  12.  
  13. if (preg_match('~[0-9]+~', $whatIWant)) {
  14.     echo $whatIWant;
  15. }else{
  16. echo $first;
  17. }
  18. }
  19.  
  20.  
  21.  
  22. ?>
Parsed in 0.008 seconds