I have the following String.
name-any-ID 12
I want a PHP expression that removes the -ID 12 string.
NOTE: The value can change as for example -ID 23.
I have the following String.
name-any-ID 12
I want a PHP expression that removes the -ID 12 string.
NOTE: The value can change as for example -ID 23.
You can use the strstr()
function to break and get the left part of the string, an important detail is to enter the third argument that returns the left part, by default it returns the right.
$str = 'nomequalquer-ID 12';
$novo = strstr($str, '-ID', true);
echo "<pre>";
print_r($novo);