Slicing PHP Strings
PHP provides the substr() function to slice strings.
Example of Slicing PHP Strings
<?php
$string = 'Hello, World!';
echo substr($string, 0, 5) . "\n";
// Outputs: Hello
echo substr($string, 7) . "\n";
// Outputs: World!
?>
Output:
Hello
World!
Explanation: This example demonstrates the use of the substr() function to slice strings in PHP.