如何在php数组中为一个键存储多个值

编程入门 行业动态 更新时间:2024-10-24 12:30:00
本文介绍了如何在php数组中为一个键存储多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我进行了很多搜索,找到了一种将多个值存储到一个键中的方法,但是我什么都没有

i searched a lot to find a way to store multiple value into one key , but i can't anything

我需要为一个键设置3个值php array

I need to set 3 value for one key in php array

是否可以做到这一点?

推荐答案

到直接回答您的问题,不。 PHP数组只能包含一组密钥数据。

To directly answer your question, no. PHP arrays can only contain one set of data for the key.

您需要使用多维数组,其中键的值是包含键和值的数组,例如:

You need to use a multidimensional array, where the value of a key is an array with keys and values, e.g.:

$array = array ( "bob" => array ( "height" => "6.0", "age" => "21", ), "joe" => array ( "height" => "5.9", "age" => "35", ) );

这里是基础知识的起点

在那之后,堆栈上已经有大量信息溢出和互联网的其余部分。搜索 php多维数组

After that, there's a mountain of info already on Stack Overflow and the rest of the internet. Search for "php multidimensional array"

搜索在堆栈上

更多推荐

如何在php数组中为一个键存储多个值

本文发布于:2023-10-21 17:26:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1514873.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   数组   中为   如何在   php

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!