Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: utf8

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5
Source code for file /phputf8/substr_replace.php

Documentation is available at substr_replace.php

  1. <?php
  2. /**
  3. * @version $Id: substr_replace.php,v 1.1 2006/02/25 13:50:17 harryf Exp $
  4. * @package utf8
  5. * @subpackage strings
  6. */
  7.  
  8. //---------------------------------------------------------------
  9. /**
  10. * UTF-8 aware substr_replace.
  11. * Note: requires utf8_substr to be loaded
  12. * @see http://www.php.net/substr_replace
  13. * @see utf8_strlen
  14. * @see utf8_substr
  15. */
  16. function utf8_substr_replace($str, $repl, $start , $length = NULL ) {
  17.     preg_match_all('/./us', $str, $ar);
  18.     preg_match_all('/./us', $repl, $rar);
  19.     if( $length === NULL ) {
  20.         $length = utf8_strlen($str);
  21.     }
  22.     array_splice( $ar[0], $start, $length, $rar[0] );
  23.     return join('',$ar[0]);
  24. }

Documentation generated on Mon, 05 Mar 2007 21:27:23 +0000 by phpDocumentor 1.3.1