How to get everything after a certain character?
You can use the strstr()
function to get everything after a certain character in a string. For example:
<?php
$string = 'Hello World';
$character = 'W';
$everything_after = strstr($string, $character);
echo $everything_after; // Outputs "World"
Watch a video course
Learn object oriented PHP
You can also use the substr()
function to achieve the same result. The substr()
function allows you to specify an offset as the second argument, which is the position of the character you want to start at. For example:
<?php
$string = 'Hello World';
$character = 'W';
$offset = strpos($string, $character);
$everything_after = substr($string, $offset);
echo $everything_after; // Outputs "World"