PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 1.0.10
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v1.0.10
3.1.14 3.1.13 3.1.12 3.1.11 3.1.10 3.1.9 3.1.8 3.1.7 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 All 123 releases
firebox / Inc / Framework / Inc / Helpers / StringHelper.php

StringHelper.php in FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment 1.0.10, at Inc/Framework/Inc/Helpers/StringHelper.php

87 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package FirePlugins Framework
4 * @version 1.0.21
5 *
6 * @author FirePlugins <[email protected]>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2022 FirePlugins All Rights Reserved
9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 */
11
12 namespace FPFramework\Helpers;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 class StringHelper
20 {
21 /**
22 * UTF-8 aware alternative to strpos()
23 *
24 * Find position of first occurrence of a string.
25 *
26 * @param string $str String being examined
27 * @param string $search String being searched for
28 * @param integer $offset Optional, specifies the position from which the search should be performed
29 *
30 * @return integer|boolean Number of characters before the first match or FALSE on failure
31 */
32 public static function strpos($str, $search, $offset = false)
33 {
34 if ($offset === false)
35 {
36 return self::utf8_strpos($str, $search);
37 }
38
39 return self::utf8_strpos($str, $search, $offset);
40 }
41
42 /**
43 * Assumes mbstring internal encoding is set to UTF-8
44 * Wrapper around mb_strpos
45 * Find position of first occurrence of a string
46 *
47 * @param string haystack
48 * @param string needle (you should validate this with utf8_is_valid)
49 * @param integer offset in characters (from left)
50 *
51 * @return mixed integer position or FALSE on failure
52 */
53 public static function utf8_strpos($str, $search, $offset = FALSE)
54 {
55 if ( $offset === FALSE ) {
56 return mb_strpos($str, $search);
57 } else {
58 return mb_strpos($str, $search, $offset);
59 }
60 }
61
62 /**
63 * Checks whether $haystack starts with $needle.
64 *
65 * @param string $haystack
66 * @param string $needle
67 *
68 * @return int
69 */
70 public static function startsWith($haystack, $needle)
71 {
72 return substr_compare($haystack, $needle, 0, strlen($needle)) === 0;
73 }
74
75 /**
76 * Checks whether $haystack ends with $needle.
77 *
78 * @param string $haystack
79 * @param string $needle
80 *
81 * @return int
82 */
83 public static function endsWith($haystack, $needle)
84 {
85 return substr_compare($haystack, $needle, -strlen($needle)) === 0;
86 }
87 }