I have a php array of key => value, and I would lượt thích to store all the values into a list (like a python list) of values.I need it cause I have to lớn pass this danh mục of values khổng lồ a JQuery script.

Bạn đang xem: Convert array to list () and shorthand for array destructuring

Basically I have:

$var = Array ( <0> => 5 <1> => 7 <2> => 9 <3> => 10 )and I would lượt thích to have something like

$var = <5, 7, 9, 10>;When I điện thoại tư vấn from Jquery my variable:

var newvariable = "";The final goal is to have a Jquery danh sách like:

var newvariable = <5,7,9,10>;Is this possible in php?





I"m assuming you have a PHP array such as this:

$var = array ( 5, 7, 9, 10 );This would print, with var_dump:

array(4) <0>=> int(5) <1>=> int(7) <2>=> int(9) <3>=> int(10)PHP has a list() language constructor <1>. I don"t believe this is what you want though.

Since I"m not sure exactly how this is constructed, I"d suggest looking at the JSON functions <2> PHP has available which might be of help when interacting with jQuery.

Not a definitive answer but I hope it helps.

Xem thêm: Mua Sữa Tắm Hazeline Chính Hãng Giá Tốt Tại Bachhoaxanh, Sữa Tắm Hazeline Có Làm Trắng Da Không


mô tả
answered Feb trăng tròn 2017 at 12:27

Hugo MartinsHugo Martins
111 bronze badge
địa chỉ cửa hàng a bình luận |

Your Answer

Thanks for contributing an answer khổng lồ Stack Overflow!

Please be sure to answer the question. Provide details and share your research!

But avoid

Asking for help, clarification, or responding to lớn other answers.Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Facebook
Sign up using thư điện tử and Password

Post as a guest

e-mail Required, but never shown

Post as a guest


Required, but never shown

Post Your Answer Discard

By clicking “Post Your Answer”, you agree khổng lồ our terms of service, privacy policy & cookie policy

Not the answer you're looking for? Browse other questions tagged php arrays or ask your own question.

The Overflow Blog
Featured on Meta
Create ArrayList from array
How vị I kiểm tra if an array includes a value in JavaScript?
Deleting an element from an array in PHP
How khổng lồ insert an công trình into an array at a specific index (JavaScript)
How bởi you check if a variable is an array in JavaScript?
Sort array of objects by string property value
Loop through an array in JavaScript
Reference — What does this symbol mean in PHP?
How can I remove a specific vật phẩm from an array?
For-each over an array in JavaScript
Hot Network Questions more hot questions

Question feed
Subscribe to RSS
Question feed to lớn subscribe khổng lồ this RSS feed, copy and paste this URL into your RSS reader.

Stack Overflow
Stack Exchange Network
site thiết kế / logo © 2022 Stack Exchange Inc; user contributions licensed under cc by-sa. Rev2022.2.11.41438

Stack Overflow works best with JavaScript enabled

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device & disclose information in accordance with our Cookie Policy.