<?php
function startsWith($haystack, $needle) {
$cutsQuantity = 2;
$parts = explode($needle, $haystack, $cutsQuantity);
return ($parts[0] === '');
}
function endsWith($haystack, $needle) {
$parts = explode($needle, $haystack);
return (array_pop($parts) === '');
}
var_dump(startsWith('The quick brown fox jumps over the lazy dog', 'The quick')); // true
var_dump(startsWith('The quick brown fox jumps over the lazy dog', 'lazy dog')); // false
var_dump(endsWith('The quick brown fox jumps over the lazy dog', 'The quick')); // false
var_dump(endsWith('The quick brown fox jumps over the lázy dog', 'lázy dog')); // true