473,396 Members | 1,755 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,396 software developers and data experts.

Problem With Arrays Of Arrays, PHP 5.2.0, Windows

$aThePosts = array_change_key_case($_POST, CASE_LOWER);

define("CONTACT_IS_LOCAL", 0);
define("CONTACT_IS_REMOTE", 1);

/* $aWho contains an array of arrays (contact details)
* array(
* array(0, CONTACT_IS_LOCAL, "My Local Contact",
* "123 Any Street", "Suite 123",
* "Phoenix", STATE_ARIZONA, "01234-5678",
* array(800, "867-5309", "867-5309",
* "1-800-000-0000", "867-5309"),
* "www.example.com"),
* array(1, CONTACT_IS_REMOTE, ...
*/
function WhichContact() {
global $aThePosts, $aWho;

if (isset($aThePosts['idWho'])) {
$iWhich = $aThePosts['idWho'];
$iWhichCheck = $aWho[$iWhich][0];
if ($iWhichCheck == $iWhich) {
return($iWhich);
}
}
return(-1);
}

I'm running into some strange problems. Sometimes,
$aWho[$iWhich][0] turns into the index number I expect,
and sometimes it returns "array[0]".

For instance, when I insert the following code after a call
to the above.

$iWho = WhichContact();
echo("<p class=\"pc\">$iWho</p>\n");
echo("<p class=\"pc\">" . $aWho[$iWho][0] . "</p>\n");
echo("<p class=\"pc\">$aWho[$iWho][0]</p>\n");

Inside the quotes, $aWho[$iWho] turns into "array" and
the string "[0]" gets added to it. Outside of the quotes
it returns the number I expect to get back.

But then when using that inside the function to verify
that a POST variable actually matches up with the index
of the client, the comparisons fail to match.

PHP 5.2.0 (cli) (built: Nov 2 2006 11:57:36)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies

Is there a way to check the internal storage type of any
particular variable?

The POST variable is a value from an HTML

<form action="./" method="POST">
<select name="idWho">
<option value="0">Local Contact</option>
<option value="1">Remote Contact</option>
</select>
</form>

--
Jim Carlock
Post replies to the group.
Jan 29 '07 #1
0 1087

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

Similar topics

7
by: csx | last post by:
Hi everyone! two quick questions relating to arrays. Q1, Is it possible to re-assign array elements? int array = {{2,4}, {4,5}}; array = {2,3}
10
by: Mark Jerde | last post by:
I'm trying to learn the very basics of using an unmanaged C++ DLL from C#. This morning I thought I was getting somewhere, successfully getting back the correct answers to a C++ " int SumArray(int...
2
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c...
7
by: HeatherS | last post by:
We are having issues with our windows services using memory and never releasing it. We have one service that has a file watcher which takes an xml file, inserts some records into a database, and...
14
by: rohitpatel9999 | last post by:
Hi While developing any software, developer need to think about it's possible enhancement for international usage and considering UNICODE. I have read many nice articles/items in advanced C++...
12
by: garyusenet | last post by:
I have had no replies to my previous post so perhaps I didn't write it good enough. Please excuse new thread but i wanted to break from the last thread hopefully this thread will be better. ...
9
by: weidongtom | last post by:
Hi, I've written the code that follows, and I use the function add_word(), it seems to work fine *before* increase_arrays() is called that uses realloc() to allocate more memory to words. But...
1
by: Alhazred | last post by:
I'm writing a client-server software which should emulate an email service on a local machine. I'm now at the beginning and I'm trying to let communicate the client and the server process, but have...
16
by: mike3 | last post by:
(I'm xposting this to both comp.lang.c++ and comp.os.ms- windows.programmer.win32 since there's Windows material in here as well as questions related to standard C++. Not sure how that'd go over...
43
by: John | last post by:
Hi This .net is driving me crazy!! In VB6 I had a type which contained a couple of multi-dimentional arrays which i used to create and read records: Type AAA : Array1(10,10,2) as Integer
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
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...
0
Oralloy
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,...
0
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...

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.