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?
$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
<1> http://php.net/manual/en/function.list.php<2> http://php.net/manual/en/ref.json.php
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.
Required, but never shown
By clicking “Post Your Answer”, you agree khổng lồ our terms of service, privacy policy & cookie policy
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.
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.