Beginner question - adding keys to existing array
Posted: Sat Mar 29, 2003 5:16 am
How can I add keys to an existing array without defining new values?
is what I have so far, and I need to change the keys of $count_array from 1,2...26 to a,b,c...z.
I know there'll be a simple answer, but please help, this is my first day with php.
Cheers!
-Ben
Code: Select all
<?php
$thebox = strtolower($_POST['thebox']);
// get form input into thebox and make it all lowercase
print "$thebox <hr>";
// prints the lowercase text to be counted, with horizontal line
$ascii_array = (count_chars($thebox));
// counts the characters in the text, and returns them in an array with ascii keys, 0 to 255
$count_array = array_slice ($ascii_array, 97, 26);
// slices out the lower case alphabet (a = 97) into a new array (a = 0)
?>I know there'll be a simple answer, but please help, this is my first day with php.
Cheers!
-Ben