Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
16 | * $Id$ |
17 | * | |
18 | */ | |
19 | ||
a1a2a83d TO |
20 | /** |
21 | * Smarty plugin | |
22 | * Type: modifier | |
23 | * Name: substring | |
24 | * Version: 0.1 | |
25 | * Date: 2006-16-02 | |
26 | * Author: Thorsten Albrecht <thor_REMOVE.THIS_@wolke7.net> | |
27 | * Purpose: "substring" allows you to retrieve a small part (substring) of a string. | |
28 | * Notes: The substring is specified by giving the start position and the length. | |
29 | * Unlike the original function substr() in PHP the position of the characters | |
30 | * in the string starts at 1 (not at 0 as usual in php). | |
31 | * Example smarty code: | |
32 | * {$my_string|substring:2:4} | |
33 | * returns substring from character 2 until character 6 | |
34 | * @link based on substr(): http://www.zend.com/manual/function.substr.php | |
6c552737 TO |
35 | * @param string $string |
36 | * @param int $position | |
37 | * startposition of the substring, beginning with 0 | |
38 | * @param int $length | |
39 | * length of substring | |
a1a2a83d | 40 | * @return string |
a1a2a83d | 41 | */ |
6a488035 TO |
42 | function smarty_modifier_substring($string, $position, $length) { |
43 | return substr($string, $position, $length); | |
44 | } |