Hello,
I've an array of array(1,2,3,4). I'd like to retrieve the values in 3 and 4
giving the values 1 and 2. How can I do that, how to search in an array of
array ? in short, how to write the findvalue function ?
$list = array();
array_push($list,array(1,1,'x','x');
array_push($list,array(1,2,'x','y');
array_push($list,array(2,1,'y','x');
array_push($list,array(2,2,'y','y');
$result = array();
$result = findvalue(1,2); //should return 'x','y'
function findvalue($a,$b){
//return the array of values...
}
Thanks for helping.
Bob 4 2834
$list = array();
array_push($list,array(1,1,'x','x');
array_push($list,array(1,2,'x','y');
array_push($list,array(2,1,'y','x');
array_push($list,array(2,2,'y','y');
$result = array();
$result = findvalue(1,2); //should return 'x','y'
function findvalue($a,$b){
//return the array of values...
}
print_r($list[1][2]);
not sure why you need a function here.
On Nov 5, 3:44 pm, "Bob Bedford" <b...@bedford.comwrote:
Hello,
I've an array of array(1,2,3,4). I'd like to retrieve the values in 3 and 4
giving the values 1 and 2. How can I do that, how to search in an array of
array ? in short, how to write the findvalue function ?
$list = array();
array_push($list,array(1,1,'x','x');
array_push($list,array(1,2,'x','y');
array_push($list,array(2,1,'y','x');
array_push($list,array(2,2,'y','y');
$result = array();
$result = findvalue(1,2); //should return 'x','y'
function findvalue($a,$b){
//return the array of values...
}
Thanks for helping.
Bob
What have you tried already?
We won't do your homeworks ;-)
On Mon, 05 Nov 2007 17:14:20 +0100, Steve <no****@example.comwrote:
>$list = array(); array_push($list,array(1,1,'x','x'); array_push($list,array(1,2,'x','y'); array_push($list,array(2,1,'y','x'); array_push($list,array(2,2,'y','y');
$result = array(); $result = findvalue(1,2); //should return 'x','y'
function findvalue($a,$b){ //return the array of values... }
print_r($list[1][2]);
Yet he wants to find the record in $list[1].
OP: for a single search a foreach loop or customized array_filter come to
mind. If you have to search a lot of entries, you might want to build an
array of references, indezing the array. Be very, very sure you need it
though, your code becomes somewhat unreadable by another coder.
--
Rik Wasmus
"Darko" <da**************@gmail.coma écrit dans le message de news: 11*********************@22g2000hsm.googlegroups.co m...
On Nov 5, 3:44 pm, "Bob Bedford" <b...@bedford.comwrote:
>Hello,
I've an array of array(1,2,3,4). I'd like to retrieve the values in 3 and 4 giving the values 1 and 2. How can I do that, how to search in an array of array ? in short, how to write the findvalue function ?
$list = array(); array_push($list,array(1,1,'x','x'); array_push($list,array(1,2,'x','y'); array_push($list,array(2,1,'y','x'); array_push($list,array(2,2,'y','y');
$result = array(); $result = findvalue(1,2); //should return 'x','y'
function findvalue($a,$b){ //return the array of values...
}
Thanks for helping.
Bob
What have you tried already?
We won't do your homeworks ;-)
I've a loop that goes trough all records of $list and check the values...not
sure is the best way to do so...my $list array contains about 1500 records
each is an array of 5 fields.
function findvalue($check1,$check2){
global $list
foreach ($list as $key =$value){
if(($value[0] = = $check1) and ($value[1] = = $check2)){
return array(strtoupper($value[3]),strtoupper($value[2]));
break;
}
}
} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: joshc |
last post by:
If I have an array of data that I know to be sorted in increasing
order, and the array is less than 50 elements, and I want to find the
first element greater than a certain value, is a simple...
|
by: cyrvb |
last post by:
Hello,
I'm a very very newbie in C# I did start 2 days ago, I get Visual
Stuido 2005 C#
I try to understand how to manage the arrays
I did write this
|
by: free2cric |
last post by:
Hi,
I have a single link list which is sorted.
structure of which is like
typedef struct mylist
{
int num;
struct mylist *next;
|
by: Martien van Wanrooij |
last post by:
I have been using phpdig in some websites but now I stored a lot of larger
texts into a mysql database. In the phpdig search engine, when you entered a
search word, the page where the search word...
|
by: lovecreatesbeauty |
last post by:
Any comments are welcome for following the two sequential search C
functions of both integer and string versions. Though they are simple,
please do not laugh at it :) Could you give your great...
|
by: mdh_2972 |
last post by:
I have an array of over 1000 links in a .JS file. I do not want to put
the whole thing on my page because it would take to long to render the
page. So how can I randomly pick 1 element from the...
|
by: flash |
last post by:
write a program that manipulates arrays of integers. The main program should call three functions: Insert, Delete, and Search. The Insert function should call a function Sort that sorts the array.
...
|
by: Atos |
last post by:
Binary search is used to locate a value in a sorted list of values.
It selects the middle element in the array of sorted values, and compares it with the target value; that is the key we are...
|
by: Debadatta Mishra |
last post by:
Introduction
In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: SueHopson |
last post by:
Hi All,
I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...
| |