Extended PHP
  • Getting started
  • Strings helpers
  • Enums helpers
  • Classes helpers
Powered by GitBook
On this page
  • is_json
  • is_json_structure
  • get_email_domain

Strings helpers

List of functions that works for PHP strings.

PreviousGetting startedNextEnums helpers

Last updated 8 months ago

is_json

Since PHP 8.3+ this function will throw a deprecated warning message to move to PHP's native function instead () which works similarly.

Check if a variable is a valid json string.

$json = '{}';

\OpenSoutheners\ExtendedPhp\Strings\is_json($json); // true

is_json_structure

Similarly than is_json function but this one also checks if the data inside the string is also a valid JSON data structure (starting with { or [):

$json = '1';

\OpenSoutheners\ExtendedPhp\Strings\is_json_structure($json); // false

get_email_domain

Get domain part from email address:

$email = 'hello@mydomain.com';

\OpenSoutheners\ExtendedPhp\Strings\get_email_domain($email); // 'mydomain.com'
json_validate