source: branches/rsr.v5.1.dev/web/punbb/include/utf8/substr_replace.php @ 8

Last change on this file since 8 was 3, checked in by dj3c1t, 13 years ago

passage a Fluxbb 1.4.7

File size: 560 bytes
RevLine 
[3]1<?php
2
3/**
4* @version $Id: substr_replace.php,v 1.1 2006/02/25 13:50:17 harryf Exp $
5* @package utf8
6* @subpackage strings
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*/
16function utf8_substr_replace($str, $repl, $start , $length=null)
17{
18        preg_match_all('/./us', $str, $ar);
19        preg_match_all('/./us', $repl, $rar);
20
21        if($length === null)
22                $length = utf8_strlen($str);
23
24        array_splice($ar[0], $start, $length, $rar[0]);
25
26        return implode($ar[0]);
27}
Note: See TracBrowser for help on using the repository browser.