HI
How do I know if the word 'position' is within this string? is there an internal function to do this?
dsgsgdñlkjslkgjlfñjgpositionfdsñlkfñkldsf
Printable View
HI
How do I know if the word 'position' is within this string? is there an internal function to do this?
dsgsgdñlkjslkgjlfñjgpositionfdsñlkfñkldsf
Yes, take a look at str_pos()
Good luck
stristr
Quote:
<?php
$string = 'Hello World!';
if(stristr($string, 'earth') === FALSE) {
echo '"earth" not found in string';
}
// outputs: "earth" not found in string
?>
Thanks!
For simply checking the presence of a substring within a string, strpos should be preferred over strstr and its variants because the former merely returns a position and the latter return the actual substring. strpos is thus more efficient.