473,236 Members | 1,791 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,236 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 1795
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
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: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

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.