PageRenderTime 48ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/WebsiteFiles/admin/bin/pear/Compat/Function/stripos.php

https://github.com/mcherryleigh/seniordesign
PHP | 70 lines | 32 code | 8 blank | 30 comment | 7 complexity | 02f65ecaaa32e5adf2abb2448710300d MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4 |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2004 The PHP Group |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 3.0 of the PHP license, |
  9. // | that is bundled with this package in the file LICENSE, and is |
  10. // | available at through the world-wide-web at |
  11. // | http://www.php.net/license/3_0.txt. |
  12. // | If you did not receive a copy of the PHP license and are unable to |
  13. // | obtain it through the world-wide-web, please send a note to |
  14. // | license@php.net so we can mail you a copy immediately. |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Aidan Lister <aidan@php.net> |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: stripos.php,v 1.6 2004/06/12 06:53:00 aidan Exp $
  20. //
  21. /**
  22. * Replace stripos()
  23. *
  24. * @category PHP
  25. * @package PHP_Compat
  26. * @link http://php.net/function.stripos
  27. * @author Aidan Lister <aidan@php.net>
  28. * @version $Revision: 1.6 $
  29. * @since PHP 5
  30. */
  31. if (!function_exists('stripos'))
  32. {
  33. function stripos ($haystack, $needle, $offset = null)
  34. {
  35. if (!is_scalar($haystack)) {
  36. trigger_error('stripos() expects parameter 1 to be string, ' . gettype($haystack) . ' given', E_USER_WARNING);
  37. return false;
  38. }
  39. if (!is_scalar($needle)) {
  40. trigger_error('stripos() needle is not a string or an integer.', E_USER_WARNING);
  41. return false;
  42. }
  43. if (!is_null($offset) && !is_numeric($offset)) {
  44. trigger_error('stripos() expects parameter 3 to be long, ' . gettype($offset) . ' given', E_USER_WARNING);
  45. return false;
  46. }
  47. // Manipulate the string if there is an offset
  48. $fix = 0;
  49. if (!is_null($offset))
  50. {
  51. if ($offset > 0)
  52. {
  53. $haystack = substr($haystack, $offset, strlen($haystack) - $offset);
  54. $fix = $offset;
  55. }
  56. }
  57. $segments = explode (strtolower($needle), strtolower($haystack), 2);
  58. $position = strlen($segments[0]) + $fix;
  59. return $position;
  60. }
  61. }
  62. ?>