473,385 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

in_array() question

hello,

I have this code sample:

class Sexboard extends Master
{
var $userid;
var $errormessage;
var $dc_metro = array(20, 46, 51);

....

function get_select_by_user_online_sql($stateid, $cityid)
{
...

if( in_array( $stateid, $this->$dc_metro ) )
{
...
}

}

}

My question is why do I get a warning message saying the wrong data type
for the second parameter?

Thanks,

Paul

Jul 17 '05 #1
4 1619

"paul brown" <pa**@paulbrown.net> wrote in message
news:1n***************@newssvr21.news.prodigy.com. ..
hello, <snip> if( in_array( $stateid, $this->$dc_metro ) )

My question is why do I get a warning message saying the wrong data type
for the second parameter?

Lose the second dollar when using object's members (and read the docs for
why):
if( in_array( $stateid, $this->dc_metro ) )

HTH
Garp
Jul 17 '05 #2
paul brown wrote:
hello,

I have this code sample:

class Sexboard extends Master
{
var $userid;
var $errormessage;
var $dc_metro = array(20, 46, 51);

...

function get_select_by_user_online_sql($stateid, $cityid)
{
...

if( in_array( $stateid, $this->$dc_metro ) )
{
...
}

}

}

My question is why do I get a warning message saying the wrong data type
for the second parameter?

Thanks,

Paul


OK, I figured it out on my own... That dollar_sign before the dc_metro
was not needed... hooray for documentation!

Paul

Jul 17 '05 #3
Garp wrote:
"paul brown" <pa**@paulbrown.net> wrote in message
news:1n***************@newssvr21.news.prodigy.com. ..
hello,


<snip>
if( in_array( $stateid, $this->$dc_metro ) )

My question is why do I get a warning message saying the wrong data type
for the second parameter?


Lose the second dollar when using object's members (and read the docs for
why):
if( in_array( $stateid, $this->dc_metro ) )

HTH
Garp


Hi, and yes this would have helped, had I not found the answer in the docs.

Thanks, though, for your response,

Paul

Jul 17 '05 #4

"paul brown" <nn**@paulbrown.net> wrote in message
news:ON***************@newssvr21.news.prodigy.com. ..
Garp wrote:
"paul brown" <pa**@paulbrown.net> wrote in message
news:1n***************@newssvr21.news.prodigy.com. ..
hello,
<snip>
if( in_array( $stateid, $this->$dc_metro ) )

My question is why do I get a warning message saying the wrong data type
for the second parameter?


Lose the second dollar when using object's members (and read the docs for why):
if( in_array( $stateid, $this->dc_metro ) )

HTH
Garp


Hi, and yes this would have helped, had I not found the answer in the

docs.
Thanks, though, for your response,

Paul


I'm still claiming credit. 8P

Garp
Jul 17 '05 #5

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

Similar topics

12
by: AJ Z | last post by:
I am using in_array() to search for a value ("other"), in order to validate a form. If I pass $_POST as the array to search PHP says that it is an invalid datatype. It is an array and if I copy...
2
by: Mountain Man | last post by:
Hi, The in_array function sometimes malfunctions on my computer yielding the error message shown below. The code shown below usually works, but sometimes doesn't. This even happens with the same...
3
by: Phil Powell | last post by:
if (is_array($_POST)) { foreach ($this->getAssocSectionsObjArray($key, $dbAP) as $obj) { print_r($obj); print_r(" in array? "); print_r(in_array($obj, $result)); print_r("<P>"); if...
6
by: Craig Keightley | last post by:
I am trying to compare values of a string entered into an array but having no results, is this possible to achieve: <?php $ids = $row_rsProduct; // A comma separated list of values...
5
by: Phil Powell | last post by:
Here is my array. Plain and simple enumerative array with values being strings. So why does this fail??? print_r(in_array('album', array_keys($boolword))); This produces FALSE or NULL....
3
by: Tom Barnes | last post by:
Check out this code: // Start Code ------------- function test_in_array($val) { $a = array('key' => $val); printf("in_array: %d, value:%s<BR>", in_array('key', $a), $a); } test_in_array(0);...
6
by: Berimor | last post by:
Hi, i've been always used the in_array() function to check availabylity of a value in array. Until today. Simple code: (do not run it tho :) ) <? function getmicrotime(){ list($usec, $sec) =...
3
by: rich | last post by:
I keep getting the error: Warning: in_array(): Wrong datatype for second argument on line 679 here is the code. I declare and fill the array $specprimA = array(); $specprimA=...
3
by: Sonnich | last post by:
The following code is an exact copy of my current code. The idea is to check 2 parts (of string arrays), and add those only once to a common array. I check for existance of an array in a string,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.