I have a list of image paths in my PHP script that I would like to pass to javascript whitout rendering them in the HTML page. I mean, I don't want people go fishing for the path's when do do a > view HTML source.
<?php
$images_str = "some/dir/001.jpg|*|some/dir/002.jpg|*|some/dir/003.jpg";
$images_arr = array('some/dir/001.jpg', 'some/dir/002.jpg', 'some/dir/003.jpg');
?>
<html>
<body>
<script type="text/javascript">
var dynamicID = 1;
/* String */
_images_str = "<?= $images_str ?>";
_images_str_arr = _images_str.split("|*|");
// alert(_images_str_arr[dynamicID]); // OK but renders the image paths in javascript
/* Array */
var _images_arr = new Array();
_images_arr = "<?= $images_arr ?>";
// alert("<?= $images_arr ?>"); // "Array"
// alert(_images_arr); // "Array"
// alert(_images_arr[1]); // "r" from "Array"
// alert("<?= $images_arr[1] ?>"); // "some/dir/002.jpg" works! but how to use dynamicID??
// alert("<?= count($images_arr) ?>"); // works as well
</script>
</body>
</html>