RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
php怎么往数组存放数据,PHP怎么定义一个数组

PHP怎样把得到的数据的值保存在一个数组里面

input 存在着2个方式 get 和post ,你可以根据你的需求去选择。

汝城ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:13518219792(备注:SSL证书合作)期待与您的合作!

现在很多框架都支持直接将post或者get到的数据作为整个数组保存哈

$input_array = $_GET['paramsName'];

参考链接:

php怎么写入、存储数组数据?

PHP有自带的高性能函数 var_export

conn.php

?php

$dbconfig = array (

'host'='127.0.0.1',

'name'='root',

'password'='123456',

?

b.php

?php

// 读取配置

include 'conn.php';

echo $dbconfig['host'];

// 修改配置

$dbconfig['host'] = 'xxx.xxx.xxx.xxx';

file_put_contents('conn.php', "?php\n$dbconfig = " . var_export($dbconfig) . "\n?");

// 再读取配置

include 'conn.php';

echo $dbconfig['host'];

?

参考连接:

如何把php 查询结果存入数组

遍历数据表,把相应的数据放到数组中即可

例如:

?php

//定义一个数组,用于保存读取到的数据

$contents = array();

$query = mysql_query("select * from table");

//遍历数据表

while($array = mysql_fetch_array($query)){

$contents[] = $array;

}

print_r($contents);

//然后循环数组,或者通过键名使用数组

foreach($contents as $value){

print_r($value);

}

echo $contents[0]['字段名称'];

?


分享文章:php怎么往数组存放数据,PHP怎么定义一个数组
当前地址:http://scyingshan.cn/article/phegho.html