note 76337 deleted from function.explode by nlopess
| From: | nlopess@php.net | Date: | Fri, 13 Jul 2007 19:10:37 +0000 |
| Subject: | note 76337 deleted from function.explode by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-128458@lists.php.net to get a copy of this message | ||
Note Submitter: Meercat9
----
I was just wondering, is there a way to get each character as an array, I did a brief scan of the
functions list and couldn't find something at first, and you can't do this in explode
because the delimerater (or whatever you call it) cannot be null.
As you can probably tell by this program, it's just a function to work out a word's value
according to the sum of the old primary school secret code of each letter representing a number
equal to its place in the alphabet.
<?php
function alpha_value($q){
$p = explode("",$q);
foreach($p as $v){
$v = strtolower($v);
if($v == 'a'){$g = 1;}
if($v == 'b'){$g = 2;}
if($v == 'c'){$g = 3;}
if($v == 'd'){$g = 4;}
if($v == 'e'){$g = 5;}
if($v == 'f'){$g = 6;}
if($v == 'g'){$g = 7;}
if($v == 'h'){$g = 8;}
if($v == 'i'){$g = 9;}
if($v == 'j'){$g = 10;}
if($v == 'k'){$g = 11;}
if($v == 'l'){$g = 12;}
if($v == 'm'){$g = 13;}
if($v == 'n'){$g = 14;}
if($v == 'o'){$g = 15;}
if($v == 'p'){$g = 16;}
if($v == 'q'){$g = 17;}
if($v == 'r'){$g = 18;}
if($v == 's'){$g = 19;}
if($v == 't'){$g = 20;}
if($v == 'u'){$g = 21;}
if($v == 'v'){$g = 22;}
if($v == 'w'){$g = 23;}
if($v == 'x'){$g = 24;}
if($v == 'y'){$g = 25;}
if($v == 'z'){$g = 26;}
$total = $total + $g;
}
return $total;
}
?>