fork download
  1. <?php
  2.  
  3. function checkstrling($input, $substring)
  4. {
  5. if (strpos($input, $substring) !== false) {
  6. return 2;
  7. }
  8. foreach (str_split($substring) as $char) {
  9. if (strpos($input, $char) === false) {
  10. return 0;
  11. }
  12. }
  13. return 1;
  14. }
  15.  
  16. print checkstrling("xgolensssx","golden"); // 0
  17. print checkstrling("abcgxyommlgdqqesn","golden"); // 1
  18. print checkstrling("xgoldensssx","golden"); // 2
  19.  
  20. print checkstrling("somegxoxdxlxnmme","golden"); // 1
  21. print checkstrling("somegxoxlxdxemnmgoldenv","golden"); // 2
Success #stdin #stdout 0.02s 23292KB
stdin
Standard input is empty
stdout
01212