PageRenderTime 40ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/test/zend/good/ext/standard/tests/strings/strrchr_variation3.php

http://github.com/facebook/hiphop-php
PHP | 31 lines | 19 code | 4 blank | 8 comment | 0 complexity | 3cf3aed34b3d5562b3000ba87776be33 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?hh
  2. /* Prototype : string strrchr(string $haystack, string $needle);
  3. * Description: Finds the last occurrence of a character in a string.
  4. * Source code: ext/standard/string.c
  5. */
  6. /* Test strrchr() function by passing multi-line heredoc string for haystack and
  7. * with various needles
  8. */
  9. <<__EntryPoint>> function main(): void {
  10. echo "*** Testing strrchr() function: with heredoc strings ***\n";
  11. $multi_line_str = <<<EOD
  12. Example of string
  13. spanning multiple lines
  14. using heredoc syntax.
  15. EOD;
  16. $needles = varray[
  17. "ing",
  18. "",
  19. " ",
  20. $multi_line_str //needle as haystack
  21. ];
  22. //loop through to test strrchr() with each needle
  23. foreach($needles as $needle) {
  24. var_dump( strrchr($multi_line_str, $needle) );
  25. }
  26. echo "*** Done ***";
  27. }