Posted: Tue May 30, 2006 9:18 pm
Not quite. I substituted letters because I didn't want to bother to refer to the ranges you specified.
You have established that you are interested in certain ASCII values, like 65-72.
First, you create an array, each element of which represents the ASCII value of a character that is acceptable.
E.g. $chars = array(61, 62, 63);
Because you want a set of non-continguous spans, you will use the range() function to save some time.
E.g. $chars_1 = range(61, 63); $chars_2 = range(65, 68);
You will mash all these little spans together, to create the complete array.
E.g. $chars = array_merge(range(61, 63), range(65, 68));
Then you will convert the raw ASCII codes into the actual characters they represent, using array_map() to apply the chr() function to each element.
$chars = array_map('chr', $chars);
Finally, you will condense the array of characters into a single long string, using implode().
E.g. $pool = implode('', $chars);
Note that you do not pass the actual characters you want to the range() function. You can, but remember that later you apply the chr() function to each item. I'm sure you don't want the result of chr(A) - you want a friggin' A. Because you intend to do this, you create ranges of the ASCII codes only.
I also suggest that you try out the code you're curious about, rather than simply asking if it's right in the forum. You will never get any work done if you have to wait for someone else to volunteer to review it.
You have established that you are interested in certain ASCII values, like 65-72.
First, you create an array, each element of which represents the ASCII value of a character that is acceptable.
E.g. $chars = array(61, 62, 63);
Because you want a set of non-continguous spans, you will use the range() function to save some time.
E.g. $chars_1 = range(61, 63); $chars_2 = range(65, 68);
You will mash all these little spans together, to create the complete array.
E.g. $chars = array_merge(range(61, 63), range(65, 68));
Then you will convert the raw ASCII codes into the actual characters they represent, using array_map() to apply the chr() function to each element.
$chars = array_map('chr', $chars);
Finally, you will condense the array of characters into a single long string, using implode().
E.g. $pool = implode('', $chars);
Note that you do not pass the actual characters you want to the range() function. You can, but remember that later you apply the chr() function to each item. I'm sure you don't want the result of chr(A) - you want a friggin' A. Because you intend to do this, you create ranges of the ASCII codes only.
I also suggest that you try out the code you're curious about, rather than simply asking if it's right in the forum. You will never get any work done if you have to wait for someone else to volunteer to review it.