I create an array like this -
$dispArray = array ("FIRST","LAST","name","ID","DIRECTPHON","MOBILE","MRMRS","myKey");
-
I search on the array like this: -
if(array_search ( $key , $searchArray )){....}
-
Using firephp, I verified that the $key value of "FIRST" was included in the row set I returned.
Also if I move FIRST into another position in the array the value is found in the $dispArray. But then the new value that is first in the array is not found.
Very puzzling. Any suggestion?
2 2617
The error in my thinking (I guess) was, I thought the "if" statement returned true or false which of course I now know it does not. So this seems to have corrected the problem. -
if(array_search ( $key , $dispArray ) === false )
-
I can test for false as it will return false if not found but will return the position in the array if found.
which now begs the question, is there a way to test for "Not false" so as to avoid this odd construct. -
if(array_search ( $key , $searchArray ) === false )
-
{
-
//do nothing
-
}else{
-
...the code I want to execute ....
-
}
-
This had me stumped for a bit too.
I found that a negation in the if statement worked to test for the opposite case - therefore
if (!($myvar===fal se)){
//code
}
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: captain_2010 |
last post by:
hi,
>From below table want only the first value of each item id.
and how to get it, tried to use top n function in select statement
it takes only the first record.
itemid qty
1 10
1 5
1 15
|
by: Robert Oschler |
last post by:
I am converting a Perl script over to "C" for a potential open source
project. I need some open source "C" code that will give me the same
functionality of a Perl Style associative array:
someArray = 6;
I know I can't get the same syntactic sugar as Perl offers, with the usage
of a string as the array key surrounded by square brackets. I just want the
general functionality, that's all. That is, a data container that will
maintain...
|
by: Harry |
last post by:
Hi,
Just seeing if anyone can help me with a problem I am having with drop
down lists.
- I have a asp:dropdownlist that gets its values from a database.
- The user then selects a value then presses the submit button.
- The submit button then calls a function that sets a asp:lable to
that value selected.
- PROBLEM: No matter what value the user selects, the asp:lable always
|
by: northshore |
last post by:
Hello,
I am creating a windows application database. I have a primary table
'Individuals' and a lookup table 'Prefixes.' In the Individuals table,
I have a column 'PrefixID' that references values of prefixes from the
Prefix table based on the PrefixID in the Prefix table.
When I load a windows application form, I can display and update data
from the primary table. This includes the prefixID value. If I
display a combo box with...
|
by: wish |
last post by:
my problem is after asort($array) then i want to print out the first value of the array?
Like this array( => april =>free =>ghost =>key)
I notice that the first index number is not a zero...and my problem is always print the first value only without know the index number..
Can some one guide me..Thanks
| |
by: no1zson |
last post by:
I have been reading through many of the array questions and cannot find one that addresses my issue. Maybe someone can help me out.
Same story, I am learning Java and have just written a CD Inventory application. It works, does what I want it to and all that, but now I need to put an array in there to store more than one cd at a time. Seems simple enough until I actually start coding. I want to save as much of the code as I can since I worked...
|
by: Arnold |
last post by:
Hi there,
In a textbox containing a string of ID numbers each separated by a
comma, how can I keep only the first value, and then remove all of the
other numbers and commas behind it? The first value may contain 1 or
2 or more characters.
Thanks much,
Eric
|
by: programmerboy |
last post by:
This questions is pretty easy, but let me ask since I wasn't able to figure it out.
why I am always getting the first value from DropDownList when I have
ddlStates.SelectedItem.Value;
Autopostback = false;
EnableViewState = true;
|
by: Moah Scout |
last post by:
Hi all!
This forum has been very usefully for the Access Beginners like me. I believe my problem can only be solved in this forum.
I have two tables (tblCustomers and tblOrders)and one form (frmOrders)for data entry, tblCustomers has the following fields:
CoID (Autonumber)
CustomerID (Text,PK)
CustomerFullName(Text)
The tblOrders has the following fields:
OrderID (Autonumber, PK)
CustomerID (Lookup Text from tblCustomers.CustomerID)
|
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...
|
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,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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();...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |