Hi All,
I'm trying to read through an array of strings, and spit out the string relevant to the array index....
for example
a: Active, Abstanence, Airy
b: Behave, Beautiful, Banana
c: Carrot, Caring
d: Dangerous, Dabble, Dooby
So if someone put in "babad" In the field, it would output
b: Behave
a: Active
b: Beautiful (because its the second B in the array)
a: Abstanence (because its the second A in the array)
d: Dangerous
Any Idea what i need to do in the processing index page. I've tried foreach, while, etc... but i can't get it right.
Thanks in advance...
|
reply to post by Im a Marty
I don't know PHP, but I think you could use an index for each array, and use it to get the right word, increasing it after that.
Or is the problem parsing the "babad"?
|
Thats the general idea of it yes, but I don't know the code on how to do it which is the problem.
I got it counting how many times each letter appears, yet I can't pull the 'second' meaning for the second time the letter appears from the
array....
Thanks anyway
|
im not too sure what you're trying to do but did you trying using multidemensional associative arrays? like..
$example=array(
"a"=>array("Active","Abstanence","Airy"),
"b"=>array("Behave", "Beautiful", "Banana"),
"c"=>array("Carrot", "Caring"),
"d"=>array("Dangerous", "Dabble", "Dooby")
);
|
reply to post by radioactive_liquid
Thats exactly how I have it....
Then in the processing page I have this..
foreach ($chars as $value) {
if ($chars[$a] == 'A')
{
print ($namearray['A'][$a]);
$a++;
}
if ($chars[$b] == 'B')
{
print ($namearray['B'][$b]);
$b++;
}
}
Each letter going to Z. Now $namearray is '$example'. and $chars is the str_split of $input.
So if i put in ABB, it should print off first meaning of A, then first meaning of B, then SECOND meaning of B. For some reason this isn' working
with the code above...
Thanks again!
[edit on 4/7/2009 by Im a Marty]
|
Ok i got it working all, thanks to everyone for helping out
Thanks again
|