Benji
Benji

Reputation: 807

jQuery and PHP, working with arrays

I'd like to post the order of my thumbnails to a text file as an array to be read and echoed by some PHP later. The current file() function in PHP looks for a character return to signal each array entry.

jQuery:

var order = $('#thumbList').sortable('toArray');

PHP:

$order=file('order.txt');
 foreach ($order as $value) {
    echo "<img src='gal/img/sml/$value' />";
}

I'm wondering what the best way would be to go about saving and reading an array between jQuery and PHP so that I wouldn't have to reformat the array for each language.

Upvotes: 0

Views: 202

Answers (1)

thejh
thejh

Reputation: 45578

Could you serialize it to JSON? PHP and Javascript (JS only with an additional library) are both able to handle it.

Upvotes: 1

Related Questions