How does one output javascript arrays in php?

Source: Internet
Author: User
How does the php array output the following images in javascript? The php array contains the url image path. PHP array format: {code...} How does the php array output the following images in javascript? The php array contains the url image path. PHP array format:

Array([0] => http://XXX/xgsyw/content/Uploads/Img/1111.jpg[1] => http://XXX/xgsyw/content/Uploads/Img/222.jpg)$('#top').bgStretcher({            images: ['images/sample-1.jpg', 'images/sample-2.jpg', 'images/sample-3.jpg', 'images/sample-4.jpg', 'images/sample-5.jpg', 'images/sample-6.jpg'],            slideDirection: 'N',            slideShowSpeed: 1000,            transitionEffect: 'fade',            sequenceMode: 'normal',        });

The problem has been disabled. cause:

Reply content:

How does the php array output the following images in javascript? The php array contains the url image path. PHP array format:

Array([0] => http://XXX/xgsyw/content/Uploads/Img/1111.jpg[1] => http://XXX/xgsyw/content/Uploads/Img/222.jpg)$('#top').bgStretcher({            images: ['images/sample-1.jpg', 'images/sample-2.jpg', 'images/sample-3.jpg', 'images/sample-4.jpg', 'images/sample-5.jpg', 'images/sample-6.jpg'],            slideDirection: 'N',            slideShowSpeed: 1000,            transitionEffect: 'fade',            sequenceMode: 'normal',        });

If you want to output JSONjson_encodeIs to convert the array to JSON,json_decodeIs to convert JSON into an array. It must be usable. You can talk about your specific problems.

If you just want to output what you mentioned

Images: ['images/sample-1.jpg ', 'images/sample-2.jpg', 'images/sample-3.jpg ', 'images/sample-4.jpg', 'images/sample-5.jpg ']
Just spell the string.

Why is an error reported for the section you gave? Isn't it an array. No textures are available in the reply. I will add them here.

Can this be done after splicing?

$array = ('a', 'b', 'c');$array = array_map(create_function('$a', 'return "\"$a\"";'), $array);$arr_js = '['.implde(',', $array).']';

However, you can consider outputting the result as a json call.


  

Is it a Json string? Encodingjson_encode($array)Decodingjson_decode()

Depressed. What should I do? Php

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.