fork download
  1. <?php
  2. $str = '3803_452.jpg';
  3. $chars = preg_split('/_/', $str, PREG_SPLIT_OFFSET_CAPTURE);
  4. if(count($chars) < 2)
  5. { $ext = pathinfo($str);
  6. $chars = $ext['filename'];
  7. echo $chars;
  8. }else
  9. { echo $chars[0];
  10. }
  11.  
Success #stdin #stdout 0.01s 82944KB
stdin
Standard input is empty
stdout
3803