Funny thing is, even the guy/gal who got mad because you made a mistake didnt even catch that $i is undefined and you are trying to add to it. And that you are using $i++ when you should better option to use $i+1 because its a foreach not a for. My next question is why does it look like that foreach is using something that isnt defined? Which yet again is something that you and your criticist should have noticed.
foreach ($myString as $str) {
$str = $pr->myvalues;
}
You are just overwriting your definition, you defined each $mystring array value as $str array value and then turned $str into a caller for $pr which completly overwrote it pretty much. Why are you even using a foreach to do that?
My question is this and this will help us help you considering your code looks like its way out of wack.
Where is $str comming from and why do you need it? Where is $pr comming from and why do you need it? Is mytext for javascript or PHP? If its for PHP then where is the variable sign? If not then do something more logical.
Based on my assumptions you should try this:
<?PHP
// This script assumes $pr is the master array and $str is the dubbed array
// It also assumes the array keys are numerals
// Tell it that $str should be $pr for this script ;)
$str=$new=$pr;
// Make sure it worked sometimes kids don't listen you know how they are
if(($str!=$pr)) {
$str=($pr);
}
print "<script type=\"text/javascript\">\n";
print "mytext = new Array();\n";
// You should take one off the total if its zero
// If you don't it will create an extra array in the JavaScript
$total=((TRUE==$str->myvalues[0])?(count($str->myvalues)-1):(count($str->myvalues)));
// If zero exists then set i to zero so it starts there
// If one is the first key then make sure it starts with 1
for(((TRUE==$str->myvalues[0])?($i=0):($i=1));($i<=$total);($i++)) {
print "mytext[{$i}]=\"{$str->myvalues[$i]}\"\n";
}
print "</script>\n";
?>