Sephy
Sephy

Reputation: 1

How to insert filename php value into javascript?

Hello i got code where i put my images in array

<?php

foreach (array_merge(glob("NU/*.[jJ][pP][gG]"),glob("NU/*.[pP][nN][gG]"),glob("NU/*.[jJ][pP][eE][gG]"),glob("NU/*.[gG][iI][fF]")) as $filename) {
}

?> 

and i got javascript where i must use this $filename! how can i put this value in javascript operations? some example would be welcome and appreciated ;)

Upvotes: 0

Views: 181

Answers (1)

spraff
spraff

Reputation: 33395

<?php
print "<script type=text/javascript>var foo=$foo</script>";
?>

All the usual caveats about the safety of code injection and string escaping apply.

Upvotes: 1

Related Questions