使用输入搜索栏,并得到一个排的输入相匹配时, [英] Search a column using an input and get a row when the input matches
问题描述
我需要一点点帮助。我GOOGLE屁滚尿流这一点,并不断得到的答案是不是我想要的。
好吧,现在让我们说这是我的数组
< PHP $店=阵列(阵列(玫瑰,1.25,15)
阵列(菊花,0.75,25)
阵列(兰花,1.15,7)
); ?>
我如何搜索这个数组。之后,我发现我需要什么,我可以选择,这个资料是找到行。选择行后,我可以选择在其中的信息,发现该行中的信息。
例如:
我想找到一个兰花的价格。因此,我将键入的兰花那就选择行兰花是在这样做后,它会在移动到第二列,并得到1.15。或者,如果我想知道需要多少的兰花有股票选择第三排。
< PHP$ =店铺阵列(阵列(玫瑰,1.25,15)
阵列(菊花,0.75,25)
阵列(兰花,1.15,7)
);$搜索=菊花;的foreach($店为$ a)
如果($ A [0] == $搜索)
回声$ A [1];?>
I need a little bit of help. I've googled the crap out of this and keep getting answers that aren't what I want.
Okay now lets say this is my array
<?php $shop = array( array("rose", 1.25 , 15),
array("daisy", 0.75 , 25),
array("orchid", 1.15 , 7)
); ?>
How can I search this array. After I find what I need I can select the row that this information was found in. After selecting the row I can choose what information in the row in which the information was found.
For example:
I want to find the price of a orchid. So I would type in orchid then it would select the row orchid was on after doing this it would move over to the second column and get 1.15. Or if I wanted to know how many orchids there were in stock it would select the third row.
<?php
$shop = array( array("rose", 1.25 , 15),
array("daisy", 0.75 , 25),
array("orchid", 1.15 , 7)
);
$search="daisy";
foreach($shop as $a)
if($a[0]==$search)
echo $a[1];
?>
这篇关于使用输入搜索栏,并得到一个排的输入相匹配时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!