source: trunk/web/punbb/include/utf8/substr_replace.php

Last change on this file was 6, checked in by dj3c1t, 13 years ago

mise a jour du trunk

File size: 560 bytes
RevLine 
[6]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.