note 100346 modified in function.substr by danbrown
| From: | danbrown@php.net | Date: | Sat, 09 Oct 2010 22:17:12 +0000 |
| Subject: | note 100346 modified in function.substr by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-173108@lists.php.net to get a copy of this message | ||
Using substr() to examine characters of a string without altering the string.
<?php
$string = 'This is my string';
$length = strlen($string);
$myChar = 'm';
for($i = 0; $i < $length; $i++) {
$showString_i = substr($string, $i, 1);
if($myChar == $showString_i) return $i;
}
?>
can also examine subs.
--was--
Using substr() to examine characters of a string without altering the string.
$string = 'This is my string';
$length = strlen($string);
$myChar = 'm';
for($i = 0; $i < $length; $i++) {
$showString_i = substr($string, $i, 1);
if($myChar == $showString_i) return $i;
}
can also examine subs.
http://php.net/manual/en/function.substr.php