Merge pull request #15649 from JMAConsulting/core-1346
[civicrm-core.git] / CRM / Core / Smarty / plugins / modifier.substring.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
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 |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 * $Id$
17 *
18 */
19
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
35 * @param string $string
36 * @param int $position
37 * startposition of the substring, beginning with 0
38 * @param int $length
39 * length of substring
40 * @return string
41 */
42 function smarty_modifier_substring($string, $position, $length) {
43 return substr($string, $position, $length);
44 }