Merge pull request #22532 from seamuslee001/dev_core_3034
[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 */
17
18 /**
19 * Smarty plugin
20 * Type: modifier
21 * Name: substring
22 * Version: 0.1
23 * Date: 2006-16-02
24 * Author: Thorsten Albrecht <thor_REMOVE.THIS_@wolke7.net>
25 * Purpose: "substring" allows you to retrieve a small part (substring) of a string.
26 * Notes: The substring is specified by giving the start position and the length.
27 * Unlike the original function substr() in PHP the position of the characters
28 * in the string starts at 1 (not at 0 as usual in php).
29 * Example smarty code:
30 * {$my_string|substring:2:4}
31 * returns substring from character 2 until character 6
32 * @link based on substr(): http://www.zend.com/manual/function.substr.php
33 * @param string $string
34 * @param int $position
35 * startposition of the substring, beginning with 0
36 * @param int $length
37 * length of substring
38 * @return string
39 */
40 function smarty_modifier_substring($string, $position, $length) {
41 return substr($string, $position, $length);
42 }