You are here: Re: Problem with array « PHP Programming Language « IT news, forums, messages
Re: Problem with array

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация