Hi !
I'd like to count all occurences in "$thiscodestring" into a "dynamic?" array and print it out after the end of the loop, how do I assign the variablenames dynamically ?
$query = "SELECT codes, status FROM table";
while ($row = mysql_fetch_assoc($result)) {
$thiscodestring = $row[codes]; // looks like "a1 c2 d3 10 15 1 a1 a1";
$singlecodes = explode(" ", $thiscodestring);
foreach($singlecodes as $thiscode) {
$$thiscode[count] = $$thiscode[count] + 1;
}
}
After all Mysql-Stuff is done I'd like to print out the counted codes, for example the code "a1" was found 100 times in all querys then $$a1[count] should be 100, c2 was found 15 times, then $$c2[count] should be 15 and so on.
Question:
How do I tell php to assign a "dynamic" variable with the name of the found string which was exploded (in this example a1, c2, d3... ) before ?!
$$ does not seem to work.
And how can I then print_r() the value if I dont know the name ?
Thanks !