|
Posted by Thomas 'PointedEars' Lahn on 02/06/06 16:51
Jasen Betts wrote:
> On 2006-02-05, Leszek <leszekt80@poczta.onet.pl> wrote:
> [...]
>> var danearray1= new Array();
>> danearray1 = danevar1.split(",");
>>
>> var suma1=0;
>> for(var i=0; i<danearray1.length; i++){
>> suma1=suma1+danearray1[i];
>> }
>> alert(suma1);
>> if(suma1==0){
>> alert("False");
>> }
>
> It's much easier to do the translation in PHP (fairly general solution:)
>
> var danearray=[["<?
> echo implode('"],["',preg_replace('/"/','\\"',$dane1));
> ?>"]];
>
> for arrays containing only numbers the following will suffice:
>
> var danearray=[[<? echo implode("],[",$dane1); ?>]];
Both create an ECMAScript-conforming array with an ECMAScript-conforming
array as only element, where each element of the inner array is needlessly
a _string_ value that may not be properly escaped. Certainly not what the
OP is looking for (his adder solution above).
>> because this is what im getting from alert(suma1):
>> 0"<? print $dane1; ?>
>>
>> what am I doing wrong?
>
> That looks like PHP isn't running...
Or the short_open_tag switch in php.ini is just "off" (and should stay
"off").
PointedEars
[Back to original message]
|