如何将PHP数组值存储到javascript变量 [英] How to store the PHP array value to javascript variable

查看:132
本文介绍了如何将PHP数组值存储到javascript变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将php数组值存储到变量并使用count函数时,我得到

正确的值,如2和3基于selection.and相同的值我传递给javascript像这样显示数组,我正在使用它总是5的长度函数,而在javascript中调试
。我想得到从php变量传递的相同值。如何获得价值请提前帮助我。



我的尝试:



 $ count = $ _ POST ['  check_list']; 
echo 值为 .var_dump($计数);
echo 数组值的计数是 .Count之间($计数);



 cnt = ' <?php echo $ count; ?>'; 
alert(cnt);
cnt.length;);

解决方案

count =


_POST [< span class =code-string>' check_list'];
echo 值为 .var_dump(

计数);
echo 数组值的计数是 .Count之间的(

when i am storing the php array value to variable and using count function i am getting
correct value like 2 and 3 based on selection.and same value i am passing to javascript like this it showing array and i am using the length function it gives always 5 while
debugging in javascript.I want get the same value which is passing from php variable .how to get the value please help me thanks in advance.

What I have tried:

$count=$_POST['check_list'];
echo "values are ".var_dump($count);
echo "count of array values are".count($count);


cnt='<?php echo $count; ?>';
  alert(cnt);
cnt.length();

解决方案

count=


_POST['check_list']; echo "values are ".var_dump(


count); echo "count of array values are".count(


这篇关于如何将PHP数组值存储到javascript变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆