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, as the string contain
more data that just .... well, the part from the options array is
there, then it is added to the folders array.
The problem is the line: if(!in_array($f olders,
$options1[$k]))
which works in the first case, but not in the other, even that it is
copy-paste.
The entire things works as excepted, though I get the error:
Warning: in_array() [function.in-array]: Wrong datatype for second
argument in C:\Inetpub\wwwr oot\some_file.p hp on line 754
The code follows
Sonnich
if($part9[$i]<>"")
{
$k=0;
while($k<count( $options1))
{
if( (strpos($part9[$i], $options1[$k])!==false))
if(!in_array($f olders, $options1[$k])) // here it works
$folders[]=$options1[$k];
$k++;
}
}
$j=0;
while(($j<count ($Details0)) && ($Details0[$j]!=$part0[$i]) )
$j++;
while(($j<count ($Details0)) && ($Details0[$j]==$part0[$i]) )
{
if($Details6[$j]<>"")
{
$k=0;
while($k<count( $options1))
{
if( (strpos($Detail s6[$j], $options1[$k])!==false))
if(!in_array($f olders, $options1[$k])) // here it does
not
$folders[]=$options1[$k];
$k++;
}
}
$j++;
} 3 1889
I reply to writer's this sentence only:
I check for existance of an array in a string, ...
With 'in_array' you can check (afaik)
- existence of a string in an array
- existence of an array in another array (since php 4.2)
bool in_array ( mixed needle, array haystack [, bool strict] )
Haystack is never a string, always an array.
But since php does autoconversion things, perhaps thats why you only get
warning level error.
But I didn't go through the actual code, this was just a guess.
P Pulkkinen wrote:
I reply to writer's this sentence only:
bool in_array ( mixed needle, array haystack [, bool strict] )
Haystack is never a string, always an array.
But I didn't go through the actual code, this was just a guess.
heh - that was it. I had those mixed up. I was probably to tired when I
wrote that :-)
Thanks
Sonnich wrote:
P Pulkkinen wrote:
>I reply to writer's this sentence only:
>bool in_array ( mixed needle, array haystack [, bool strict] )
Haystack is never a string, always an array. But I didn't go through the actual code, this was just a guess.
heh - that was it. I had those mixed up. I was probably to tired when
I wrote that :-)
Hehe, I still get them mixed up too, for some reason it's some weakness of
mine...
What help is comparing the saying "tofind a needle(1) in a haystack(2)" to
the wrong "to search a haystack(1) for a needle(2)", which luckily works
with the identical saying in dutch for me :-).
--
Rik Wasmus This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: S.Shaigany |
last post by:
Hi everybody,
Please help me. I have a problem with my login page, which worked fine
during the last one month. I have'nt made any changes in it. but from
yesterday on, it seems that my PHP code receives wrong POST variables.
This is my HTML code piece which just produces login form:
<form name="login" action="default.php" method="post">
UserName:<input type="text" name="username" size="15" maxlength="20"
|
by: Google Mike |
last post by:
Imagine your web hosting provider just permitted you to type
*.mydomain.com and you still get to the mydomain.com website that they
host for you. Imagine you want to setup websites for your family like
dad.mydomain.com, mom.mydomain.com, etc.
Well, this is a request and some information for you. First, here's
how you could use PHP to react to what they type in the URL:
<!-- save as index.php in /var/www/html on Linux Apache: -->
<?php
|
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 it to another variable (i.e. $list =
$_POST;) it works fine.
The same is also true of implode().
Do you believe this is intended or is it a bug?
--
|
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 (!in_array($obj, $result)) array_push($result, $obj);
}
}
|
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);
test_in_array(1);
| |
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) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
|
by: Jeff Gardner |
last post by:
Greetings:
I am attempting to get conditional output based on POSTed form data.
If the posted value is either the key or value of an array, $x=key and
$q=foo. elseif it is neither key nor value(I tried || too) , $q=bar.
Even though $x is properly assigned the new value, $q always ends up
being bar. Abstractions aside, here's the code: (note ## comments
added to this post)
<snip>
|
by: rich |
last post by:
I have 2 arrays. I am trying to use in_array with and it doesn't seem
to be working. I have done a print_r of each one for my test data.
Array $primsecA is below:
Array ( =Array ( =1 =Primary ) =>
Array ( =2 =Secondary ) =Array (
=3 =Skin Protectors ) )
Array $specprimA is below.
|
by: Nosferatum |
last post by:
This script is meant to limit access by sessions, using username and
password from mysql db and redirect users after login according to a
given value belonging to each user in the db (10,20,30,40).
(the included config is just server settings, the login is just a
login form).
The script appear to connect but will not redirect users, it seems
that even with correct login details, it won't validate.
|
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: 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: 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,...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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...
| |