473,665 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Better multidimensiona l search

Hello all,
I'm pretty sure there's a better way to do this without having to explore
the whole array until a match is found, but the solution escapes me at the
moment:

foreach ($Array as $key)
if ($key[1]===$Whatever) {
$Found=$key[0];
break;
}

--
Guillaume Dargaud
http://www.gdargaud.net/
Jan 16 '08 #1
2 1317
On 16 Sty, 23:32, "Guillaume Dargaud" <USE_MY_WEB_F.. .@gdargaud.net>
wrote:
I'm pretty sure there's a better way to do this without having to explore
the whole array until a match is found, but the solution escapes me at the
moment:

foreach ($Array as $key)
if ($key[1]===$Whatever) {
$Found=$key[0];
break;
}
If you're looking for key instead of item you should write:

foreach( $array as $key =$item )...

looking for item? use array_search.
Jan 16 '08 #2
If you're looking for key instead of item you should write:
foreach( $array as $key =$item )...
Right, I should have written $item
looking for item? use array_search.
Hmmm... But I'm looking only in the 2nd 'column' of a 2D array. array_search
or in_array don't let me narrow down the search for a specific column. How
can I do that ?

--
Guillaume Dargaud
http://www.gdargaud.net/
Jan 17 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1524
by: Ivan | last post by:
In my HTML forms (created by PHP) for attribute names I have been using multidimensional arrays as illustrated in the following: <table> <tr> <td> ID </td> <td> <input TYPE=hidden Name=frm_s Value=1661></td> <td> <input TYPE=hidden Name=frm_s Value=1662></td> <td> <input TYPE=hidden Name=frm_s Value=1663></td>
2
1360
by: Henrik | last post by:
im reciving an error when i tries to read multidimensional XML data, into my system. I'm receving the same errors discriped at: http://support.microsoft.com/default.aspx?scid=kb;en-us;325695 And http://support.microsoft.com/kb/325696/EN-US/ But I can't find a solution for the problem???
3
1867
by: matthewburton | last post by:
Hi everyone, I'm trying to write a program that will search a body of text and replace certain words (say, A, B, and C) with different words that I think are more appropriate (A1, B1 and C1). I have a feeling that I need to do this through a multidimensional array. Am I on the right track? thanks, matt
3
1341
by: BobbyS | last post by:
I am trying to develop a multidimensional array for use of searching a very large database. I understand the concept of one and two dimensional arrays but this project would include up to 12 or 13 criteiras for the search. The engine needs to be user friendly for general public use so the SQL/query path method is not really an option for me. I have heard or read about multidimensional cube arrays and am not sure if this is a viable method...
1
1506
by: tarscher | last post by:
Hi all, 2 array questions; I have a multidimensional matrix. C1 C2 C3 C4 R1 R2 R3 R4 R5
2
3615
by: BB | last post by:
Hello, I have a HTML form containing multidimensional selects listing equipments and their quantitites. This allow the users to select the kind of equipment and quantitites they would like to book. Upon onChange select event I would like to parse the data into a multidimensional Javascript array in order to check equipment availability for booking. But I can't figure out how to parse and upon JS HTML DOM reference I am not even sure...
5
2313
by: LittleCake | last post by:
Hi All, I have a multidimensional array where each sub-array contains just two entries, which indicates a relationship between those two entries. for example the first sub-array: =Array ( =30 =31 )
1
1441
by: kardon33 | last post by:
Good day all, First, I am rather new to C programming or at least don't use it enough to get used to it. My question, What part of my script needs to do is monitor a port and record the PACKETS and WHO sent them into a multidimensional array. Also I want it to know if that IP address is already in the array and if it is just update the PACKET. Like:
9
4494
by: Slain | last post by:
I need to convert a an array to a multidimensional one. Since I need to wrok with existing code, I need to modify a declaration which looks like this In the .h file int *x; in a initialize function: x = new int;
0
8438
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8348
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8549
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6187
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5660
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4356
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2765
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1761
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.