问题标签 [array-key]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
php - 读取数组二维的键
我尝试读取数组的一些键,例如
数组(3){
["poste5:"]=> array(3) { [0]=> string(7) "APPLE:" [1]=> string(5) "demo1" [2]=> string(5) "demo2" }
["服务:"]=> 数组(4) { [0]=> 字符串(9) "橙色" [1]=> 字符串(5) "demo3" [2]=> 字符串(5) "demo4" [ 3]=> 字符串(5) "demo1" }
["essai:"]=> 数组(2) { [0]=> 字符串(6) "sd" } }
我试着读这个名字:poste5、services、essai
如果我使用:
我有:数组()
但如果我使用:
我有poste5 , services , essai
我尝试使用这个循环foreach ($this->aliasRead as $key => $value){ 因为我之后有另一个特征。如何在这个循环foreach ($this->aliasRead as $key => $value){中收集我的第一个循环的这个键?
javascript - Why does the typeof a numerical array index in a "for..in" loop considered a string?
I noticed that in Javascript a variable used as the index in a for..in
loop will be always a string
even if I define it the following way:
Why is it considered a string
and not a number
?
php - 数组键会丢失,因为它们被视为数字
假设存在一个数组:
现在假设有人想要反转该数组:
问题是,这array_reverse
似乎将所有数值转换为整数,然后重置索引:
有人可能也尝试过的是这个 - 但没有任何运气(如预期的那样):
您甚至可以在键盘上亲自体验。
如何解决?我是否必须编写自己的映射函数,它可以处理这个问题还是有其他方法?
php - 如何从匹配模式的数组键中获取最大数量
我有一个数组
如何找到键中的最大数量/计数为 4,它与模式图像 [] 匹配。
感谢任何帮助。
php - PHP:搜索 id 标签@.html 文件
我有这个简单的代码,我想在 .html 文件上搜索一些标签,但我遇到了一些错误,我是 php 新手,遇到了“preg_match”命令。
这是我的简单代码:
它给了我一个错误警告:preg_match() 期望参数 1 是字符串,数组中给出
如果test.html文件中存在“id=test”测试,上面的代码会在test.html中搜索。
php - PHP:php和.html文件分离
我目前正在分离 HTML 和 PHP 代码,这是我目前正在为我工作的代码。
代码.php
测试.html
输出:一个
它搜索并将#text#值更改为 array_value A它对我有用。
现在我正在编写一个代码来搜索html 文件上的“id”标签。如果它在“.html”文件中搜索“id” ,它会将array_values放在>的中间
前任:<div id="test"> **aray_values here** </div>
测试.php
测试.html
我的问题是我不知道如何将 array_values 放在></
.html文件中每个搜索的中间。
所需的输出:<div id="test" >A</div>
php - PHP foreach 循环,带有用于过滤数组的 array_key 条件
这可能是一个非常明显的问题,但无论如何......
我有一个循环来从多维数组创建过滤结果,
但是,如果 array_keys 搜索没有结果,我需要在数组中创建一个节点以指定未找到数据等。
php - 如何按位置获取 PHP 数组中的键?
我有一个数组,仅当值不为空时才在其中存储键值对。我想知道如何检索数组中的键?
感谢您的帮助
php - 在多维数组索引/键中使用的 php 安全字符串
我想使用来自解析外部 XML 文档的字符串作为数组中的索引。由于我不知道该文档中保存了什么样的字符串 - 我应该使用任何检查或清理过程来确保没有一个字符串 php 不能用作数组中的键?
以下回答了我关于所用字符串大小的问题(仅受可用内存限制),但不回答是否有任何特殊类型的字符不能用作键:PHP 数组键有大小限制吗?PHP 数组的一般限制是什么?