Hopsel: wiedereinmal js arrays und php

Beitrag lesen

Hi Stefan!

aber beim aufruf happerts. wie kann ich dieser funktion das array übergeben?

Relativ einfach:

$colors = array();  
foreach($_SESSION['stored'] as $color)  
  $colors[] = "'".$color."'";  
echo 'loadColor (['.implode(',',$colors).'])';

Um einer Javascript-Funktion ein Array zu übergeben, musst du also einen String generieren, der folgendermaßen aufgebaut ist:
['foo','bar','foobar']

MfG H☼psel

--
"It's amazing I won. I was running against peace, prosperity, and incumbency."
George W. Bush speaking to Swedish Prime Minister unaware a live television camera was still rolling, June 14, 2001
Selfcode: ie:% fl:( br:> va:) ls:& fo:) rl:? n4:& ss:| de:] js:| ch:? sh:( mo:) zu:)