我有一个返回一个元素$ name的数组,我想用另一个名称来显示它,例如:
$ name ='PC',我想将它显示为'PC COMPUTER',第一个数组显示的元素至少为真,如何将这个元素与另一个数组进行比较以显示其他名字?
I have one array that returns one element $name, and I want to display it with another name, For example:
$name = 'PC' and I want to display it as 'PC COMPUTER', first array displays element wich is true, how to compare this elements with another array to display it with that other names?
最满意答案
难道你不能只制作第二个数组并用更多的描述性名称加载它,然后使用第一个作为关键字?
$name = 'PC'; $description = array('PC' => 'PC COMPUTER'); echo $descriptions[$name];那是你在找什么?
Can't you just make a second array and load it up with more descriptive names, then use the first as a key?
$name = 'PC'; $description = array('PC' => 'PC COMPUTER'); echo $descriptions[$name];Is that what you are looking for?
如何在PHP中使用其他名称显示数组中的内容?(How to display something from array with another name in PHP?)我有一个返回一个元素$ name的数组,我想用另一个名称来显示它,例如:
$ name ='PC',我想将它显示为'PC COMPUTER',第一个数组显示的元素至少为真,如何将这个元素与另一个数组进行比较以显示其他名字?
I have one array that returns one element $name, and I want to display it with another name, For example:
$name = 'PC' and I want to display it as 'PC COMPUTER', first array displays element wich is true, how to compare this elements with another array to display it with that other names?
最满意答案
难道你不能只制作第二个数组并用更多的描述性名称加载它,然后使用第一个作为关键字?
$name = 'PC'; $description = array('PC' => 'PC COMPUTER'); echo $descriptions[$name];那是你在找什么?
Can't you just make a second array and load it up with more descriptive names, then use the first as a key?
$name = 'PC'; $description = array('PC' => 'PC COMPUTER'); echo $descriptions[$name];Is that what you are looking for?
发布评论