ID:               33615
 User updated by:  Wojciech dot Szela at gmail dot com
 Reported By:      Wojciech dot Szela at gmail dot com
-Status:           No Feedback
+Status:           Open
 Bug Type:         Arrays related
 Operating System: Windows XP Professional SP2
 PHP Version:      5.0.4
 New Comment:

Work fine with CVS version.


Previous Comments:
------------------------------------------------------------------------

[2005-07-16 01:00:04] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

------------------------------------------------------------------------

[2005-07-08 12:31:27] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip



------------------------------------------------------------------------

[2005-07-08 12:25:38] Wojciech dot Szela at gmail dot com

Description:
------------
1. Create array and store it in $_SESSION, eg.
2. Write method which goes trough all elements of new structure
searching for particular element (use foreach), and when founds it,
call very same function looking for other element. Take a look at a
code.
Work perfectly on Linux. On Windows function looses state (index) of
foreach, so you have to change line:
foreach($_SESSION['application'] as $key => $value) {
to
$foo = $_SESSION;
foreach($foo as $key => $value) {


Reproduce code:
---------------
$_SESSION['application'] = array(
   array( 'name' => 'l1', 'symbol' => 'l1', 'father' => 'root'),
   array( 'name' => 'l1-1', 'symbol' => 'l1-1', 'father' => 'l1'),
   array( 'name' => 'l1-2', 'symbol' => 'l1-2', 'father' => 'l1'),
   array( 'name' => 'l2', 'symbol' => 'l2', 'father' => 'root'),
 );
function getTreeNodes($father) {
  $ret = array();
  foreach($_SESSION['application'] as $key => $value) {
    if($value['father'] == $father) {
      $child = array( 'symbol' => $key, 'name' =>
$value['name'], 'child' => array());
      $child['child'] = $this->getTreeNodes($key);
      $ret[] = $child;
    }
  }
  return $ret;
}
$tree = array();
$tree[] = array( 'symbol' => 'root', 'name' => 'Aplikacje', 'child' =>
array() );
$tree[0]['child'] = $this->getTreeNodes('root');
print_r($tree);


Expected result:
----------------
array of arrays (tree)
root
 - l1
   - l1-1
   - l1-2
 - l2

Actual result:
--------------
array of arrays (one branch)
root
 - l1
   - l1-1


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=33615&edit=1

Reply via email to