Overview

Namespaces

  • None
  • VSP
    • Core
      • Abstracts
      • Interfaces
      • Traits
        • WC_Compatibility
    • Deprecation
    • Helper
    • Modules
      • Addons
      • Logger

Traits

  • Array_Helper
  • Framework
  • String_Helper
  • URL
  • WC_Helper
  • WP
  • Overview
  • Namespace
  • Class

Trait String_Helper

Trait VSP_String_Trait

Direct Known Users

VSP\Helper
Namespace: VSP\Core\Traits
Author: Varun Sridharan varunsridharan23@gmail.com
Located at includes/core/traits/class-string-helper.php
Methods summary
public static boolean
# str_starts_with( string $haystack, string $needle )

Returns true if the haystack string starts with needle

Returns true if the haystack string starts with needle

Note: case-sensitive

Parameters

$haystack
$needle

Returns

boolean
public static string
# str_to_ascii( string $string )

Returns a string with all non-ASCII characters removed. This is useful for any string functions that expect only ASCII chars and can't safely handle UTF-8. Note this only allows ASCII chars in the range 33-126 (newlines/carriage returns are stripped)

Returns a string with all non-ASCII characters removed. This is useful for any string functions that expect only ASCII chars and can't safely handle UTF-8. Note this only allows ASCII chars in the range 33-126 (newlines/carriage returns are stripped)

Parameters

$string
string to make ASCII

Returns

string
public static boolean
# str_ends_with( string $haystack, string $needle )

Return true if the haystack string ends with needle Note: case-sensitive

Return true if the haystack string ends with needle Note: case-sensitive

Parameters

$haystack
$needle

Returns

boolean
public static boolean
# str_exists( string $haystack, string $needle )

Returns true if the needle exists in haystack Note: case-sensitive

Returns true if the needle exists in haystack Note: case-sensitive

Parameters

$haystack
$needle

Returns

boolean
public static string
# str_truncate( string $string, integer $length, string $omission = '...' )

Truncates a given $string after a given $length if string is longer than $length. The last characters will be replaced with the $omission string for a total length not exceeding $length

Truncates a given $string after a given $length if string is longer than $length. The last characters will be replaced with the $omission string for a total length not exceeding $length

Parameters

$string
text to truncate
$length
total desired length of string, including omission
$omission
omission text, defaults to '...'

Returns

string
public static string
# to_human_bytes( $bytes, integer $precision = 2 )

Converts Numeric Value into Human Readable View

Converts Numeric Value into Human Readable View

Parameters

$bytes
$precision

Returns

string

Example

1024B => 1KB | 1024KB => 1MB | 1024MB => 1GB
Properties summary
protected static string $mb_enc

MB_ENCODING

MB_ENCODING

# 'UTF-8'
API documentation generated by ApiGen