I have an array whose elements needs to have a generic name. I have the code almost working. Right now, the variables I want to use might have something along the lines of this:
_lang1 3
_lang15 4
_lang9 1
_lang33 16
I chose this method as the other method lists some 30 different languages and unless there is a better way, a portable method such as this seems to be the best way as the selections are all over the board.
The numbers at the end of lang are appended on the fly. What I would like to do is strip the numbers off lang and rename them as
_lang1 3
_lang2 4
_lang3 1
_lang4 16
Here's the loop that processes the code. Variables $i, $j, & $k are all defined outside the loop.
foreach ($arr as $ele) {
$samp=$width/$num;
$str .= "<td width=$samp><p><input type=\"checkbox\" name=\"$ele->subset$j\" value=\"$ele->id\"";
$j++;
foreach ($checked as $entry) {
if ($entry == $ele->name) {
$str= remove_numbers($ele->subset$j, $k);
$k++;
$str .= "checked";
continue;
}
}
function remove_numbers($string,$k) {
$rmv = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0", " ");
$string = str_replace($rmv, '', $string);
$string .= $k;
return $string;
}