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

Passing an Array to a Class

Bob
When I try to pass an array to a class the program hangs up.

php4, windows xp pro

This debug is going real slow due to having to reboot after every test
run.

Any help would be greatly appreciated!

the function in the calling program:

$new_session->set_serial_numbers('$serial_number_array');

usage in the class:

var $sn_array=array();

function set_serial_numbers($serial_number_array)
{$this->sn_array=$serial_number_array;}

for ($q=0;$q<count($this->sn_array);$q)
{echo $this->sn_array{$q}."<br>";}

Jul 17 '05 #1
5 1798
Bob wrote:

Hi Bob
$new_session->set_serial_numbers('$serial_number_array');


Should that be:
$new_session->set_serial_numbers("$serial_number_array");
???

You use ' and a variable inside ' do not get replace by its value.
It does inside "

$a = "hello";
echo "$a"; // output: hello
echo '$a'; // output: $a

not sure if that is the problem though, but it looks like a mistake.

Good luck,
Erwin Moller
Jul 17 '05 #2
Bob
No that is not it.
I just tried it, and I had to "halt the process".
Thanks for the try!
Bob

Jul 17 '05 #3
Bob wrote:
When I try to pass an array to a class the program hangs up.
<snip>
for ($q=0;$q<count($this->sn_array);$q)
{echo $this->sn_array{$q}."<br>";}


Where is $q changed in this loop?

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Jul 17 '05 #4
Your problem is here:
$new_session->set_serial_numbers('$serial_number_array');

if you are passing an array you needn't use any form of quotes! This
will actually pass the string "array()"

Jul 17 '05 #5
Bob
That is it!
Bless your soul!
I was looking in the wrong place.
Many thanks.
Bob

Jul 17 '05 #6

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

Similar topics

15
by: Dave | last post by:
I'm currently working on a small project (admitedly for my CS class) that compares the time difference between passing by value and passing by reference. I'm passing an array of 50000 int's. ...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
9
by: justanotherguy63 | last post by:
Hi, I am designing an application where to preserve the hierachy and for code substitability, I need to pass an array of derived class object in place of an array of base class object. Since I...
8
by: kalinga1234 | last post by:
there is a problem regarding passing array of characters to another function(without using structures,pointer etc,).can anybody help me to solve the problem.
3
by: Steve B. | last post by:
Can't pass an array from one class to another. Steve Class Form1 { public string dGridTitles = new string {"xyz",,,,,}; public string getdGridTitles() {
1
by: Darsin | last post by:
Hi all, I am a new programmer to C# and i am having a following problem. I want to make a single method which takes a variable length array and display it contents. i have defined the method as:...
3
by: Mark | last post by:
Hi From what I understand, you can pass arrays from classic ASP to .NET using interop, but you have to change the type of the.NET parameter to object. This seems to be because classic ASP passes...
3
by: Stephen Travis | last post by:
I'm trying to write a subroutine that will fill an array of some type with several objects of that type. The subroutine works fine if I directly reference the array but if I pass the array as an...
9
by: Greger | last post by:
Hi, I am building an architecture that passes my custom objects to and from webservices. (Our internal architecture requires me to use webservices to any suggestion to use other remoting...
17
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hi Gurus, I need to transfer a jagged array of byte by reference to unmanaged function, The unmanaged code should changed the values of the array, and when the unmanaged function returns I need...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.