Answers for "php index of string"

PHP
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
0

strpos in php

<?php
// We can search for the character, ignoring anything before the offset
$newstring = 'abcdef abcdef';
$pos = strpos($newstring, 'a', 1); // $pos = 7, not 0
?>
Posted by: Guest on November-18-2020
0

index the string php

<?php
// Get the first character of a string
$str = 'This is a test.';
$first = $str[0];

// Get the third character of a string
$third = $str[2];

// Get the last character of a string.
$str = 'This is still a test.';
$last = $str[strlen($str)-1];

// Modify the last character of a string
$str = 'Look at the sea';
$str[strlen($str)-1] = 'e';

?>
Posted by: Guest on July-15-2021

Browse Popular Code Answers by Language