Answers for "how to get position of character in string php"

PHP
13

strpos in php

<?php
$mystring = 'abc';
$findme   = 'a';
$pos = strpos($mystring, $findme);

// Note our use of ===.  Simply == would not work as expected
// because the position of 'a' was the 0th (first) character.
if ($pos === false) {
    echo "The string '$findme' was not found in the string '$mystring'";
} else {
    echo "The string '$findme' was found in the string '$mystring'";
    echo " and exists at position $pos";
}
?>
Posted by: Guest on March-13-2020
0

find index of a character in a string php

<?php
echo strpos("I love php, I love php too!","php");
?>
Posted by: Guest on May-23-2021
1

php get char from string position

//You can use your string the same as an array :
$some_string = "apple";
echo $some_string[2]; //echo "p"
Posted by: Guest on July-12-2021

Code answers related to "how to get position of character in string php"

Browse Popular Code Answers by Language