<?php
function myhash($text) {
$nr = 0;
for ($i=0; $i<strlen($text); $i++) {
$nr += ord($text[$i]);
} //for
return $tall;
}
echo myhash("M");
?>
"77"
What does the $i inside the do?
I removed it and I got the same result.
anyone?
<?php
function myhash($text) {
$nr = 0;
for ($i=0; $i<strlen($text); $i++) {
$nr += ord($text[$i]);
} //for
return $tall;
}
echo myhash("M");
?>
"77"
What does the $i inside the do?
I removed it and I got the same result.
anyone?
It refers to an iteration of the array $text
if there is only one cell, then it may not make any difference. However, there may be situations when there will be cells to be iterated. removing the index will crash the script and/ or give unexpected results.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.