473,406 Members | 2,220 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,406 software developers and data experts.

problems with list..

I have a function returning smth like list($a,$b):

var_dump says:

list(string $a, string $b) blabla()

How can use this strings now? I try:

list($a, $b) = blabla();
print($a);

but it's won't work returning empty string.

I tried also:

$result = blabla();
print $result[0];

but it also won't work.

The only thing I can do is to iterate result with foreach, then it works
nicely, but how should I use the result of blabla() function without
foreach? I just want to get to $a and $b.
Jul 25 '07 #1
5 1130
On Jul 25, 1:57 pm, Sergei Riaguzov <he...@world.comwrote:
I have a function returning smth like list($a,$b):

var_dump says:

list(string $a, string $b) blabla()
This doesn't make sense. I cannot imagine that var_dump() outputs
this.
How can use this strings now? I try:

list($a, $b) = blabla();
print($a);
This is the right way. You probably have blabla() returning the right
things if this don't work. You probably have to use array() in
blabla().

function blabla() {
// note: use array() to construct an array, not list()
return array("some", "thing");
}

list($one, $two) = blabla();

Jul 25 '07 #2
On Wed, 25 Jul 2007 05:00:43 -0700, Sjoerd wrote:
>I have a function returning smth like list($a,$b):
var_dump says:
list(string $a, string $b) blabla()
This doesn't make sense. I cannot imagine that var_dump() outputs this.
This function is generated by SoapClient from WSDL, so I can't change it.
function blabla() {
// note: use array() to construct an array, not list() return
array("some", "thing");
}

list($one, $two) = blabla();
I tried applying array(blabla()) but it won't work either. I can only
iterate the result with foreach...

Jul 25 '07 #3
Rik
On Wed, 25 Jul 2007 14:05:12 +0200, Sergei Riaguzov <he***@world.com
wrote:
On Wed, 25 Jul 2007 05:00:43 -0700, Sjoerd wrote:
>>I have a function returning smth like list($a,$b):
var_dump says:
list(string $a, string $b) blabla()
This doesn't make sense. I cannot imagine that var_dump() outputs this.
This function is generated by SoapClient from WSDL, so I can't change it.
>function blabla() {
// note: use array() to construct an array, not list() return
array("some", "thing");
}

list($one, $two) = blabla();
I tried applying array(blabla())
Huh?
but it won't work either. I can only
iterate the result with foreach...
if it is an array, and you cannout use list(), the array may not be
numerically indexed.
--
Rik Wasmus
Jul 25 '07 #4
On Wed, 25 Jul 2007 14:08:58 +0200, Rik wrote:
>>list($one, $two) = blabla();
I tried applying array(blabla())
Huh?
I'm a little bit confused by this list/array thing so that was probably
the stupid thing..
>but it won't work either. I can only
iterate the result with foreach...
if it is an array, and you cannout use list(), the array may not be
numerically indexed.
Thanx for a hint!

I ended up with smth like:

$result = blabla();
$a = array_shift($result);
$b = array_shift($result);
Jul 25 '07 #5
..oO(Sergei Riaguzov)
>$result = blabla();
$a = array_shift($result);
$b = array_shift($result);
You could also try to re-index the array numerically:

list($a, $b) = array_values(blabla());

Micha
Jul 25 '07 #6

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

Similar topics

1
by: Johnny | last post by:
Hi together, I'm new to XML and have problems with FOP (http://www.apache.org/dyn/closer.cgi/xml/fop) When I try to convert my .fo document to .pdf, I get this message: fo:39:26...
14
by: Jim Hubbard | last post by:
Are you up to speed on the difficulties in using the 1.1 .Net framework? Not if you are unaware of the 1,596 issues listed at KBAlertz (http://www.kbalertz.com/technology_3.aspx). If you are...
4
by: jhonyxxx | last post by:
I have the next programa in C++: #include <iostream.h> // C++ I/O routines #include <list.h> // The STL list class #include<stdio.h> #include <string.h> typedef struct { char nombre; int...
12
by: Eva | last post by:
Hi, I try to implement quick sort. I sort vectors by their first value. 10 2 3 4 9 3 5 6 10 4 5 6 must be 9 3 5 6 10 2 3 4 10 4 5 6 The prog works great on maybe 500 vectors, but I have an...
10
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ...
17
by: Lloyd Sheen | last post by:
This IDE is driving me nuts. I needed another button so I copied an existing one, changed the Text and the id and position by drag and drop. Well then I run and get the following: Control...
2
by: Eric Lindsay | last post by:
I have been trying to do a CSS liquid layout imitating a frame, using position: fixed for header, footer, and side navigation, and a fixed background image. Page is valid HTML 4.01 Strict, and is...
1
by: Zbigniew | last post by:
Hi, Compiler: GCC 3.3.5 OS: SuSE Linux (Kernel: 2.6.11) I reorganized my source code and now almost all my header files went to "Include" folder. Now when compiling with -I option I have...
84
by: jacob navia | last post by:
As many people know, I think that garbage collection is a good solution for many memory allocation problems. I am aware however, that nothing is "the silver bullet", not even the GC. A recent...
34
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: Traceback (most recent call last): File...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
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...

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.