By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

Output out of order?

P: n/a
Running on a single-cp machine under W2K, this test program

<?php
function show_array ( $s, $a )
{
echo '<table cellspacing="2" cellpadding="2 border="1" >
<tr><td>======&nbsp;' . $s . '&nbsp;======</td></tr>' ;
if ( ! is_array($a) ) { echo '<br>not an array!<br>' ; return ; }
foreach ( $a as $k => $v )
{
echo '<tr>' ;
if ( is_array( $v ) ) show_array( $k, $v ) ;
else echo '<td>' . $k . '</td><td>' . $v . '</td>' ;
echo '</tr>' ;
}

$a = array( 3,4,5 ) ;
$b = array( 30,40,50 ) ;

$c = array( 'foo' => $a, 'bar' => $b ) ;
$d = array( $a, $b ) ;

show_array( 'c', $c ) ;
show_array( 'd', $d ) ;
flush() ;

$x = array_splice( $c['foo'], 1, 1 ) ;
$y = array_splice( $d[0], 1, 1 ) ;

echo 'x is ' . $x[0] . ' and y is ' . $y[0] ;

show_array( 'c', $c ) ;
show_array( 'd', $d ) ;
flush() ;

}

....consistently shows the output from the 'x is ... y is' statement
during the output of the *first* call to show_array('d') (specifically
between $d[0] and $d[1]).

I can't imagine what could be going on. This looks like there's an
internal race condition of some kind, which I find very disturbing.
I'm used to serial execution such that the total output of any
subprogram will be queued to the CIO buffer before the output of
statements that follow the subprogram call.

Does anyone know what's going on here? I'm hoping it's something
simple, obvious, and dumb that I'm just not seeing.

TIA,
Margaret
--
(To mail me, please change .not.invalid to .net, first.
Apologies for the inconvenience.)
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Margaret MacDonald wrote:
Does anyone know what's going on here? I'm hoping it's something
simple, obvious, and dumb that I'm just not seeing.


One thing that's going on, is that you have placed the function calls inside
the function, so it never gets executed.

Besides that, the output is consistant with the input.
JW

Jul 17 '05 #2

P: n/a
Janwillem Borleffs wrote:
Margaret MacDonald wrote:
Does anyone know what's going on here? I'm hoping it's something
simple, obvious, and dumb that I'm just not seeing.


One thing that's going on, is that you have placed the function calls inside
the function, so it never gets executed.

Besides that, the output is consistant with the input.


oops, sorry, Janwillem, that's a typo...I missed out the closing curly
bracket when I cut and pasted. The function closes immediately after
the foreach loop.

Margaret
--
(To mail me, please change .not.invalid to .net, first.
Apologies for the inconvenience.)
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.