Req #53766 [NEW]: make RecursiveTreeIterator maintain prefix when values contain \n

From: Date: Mon, 17 Jan 2011 11:47:25 +0000
Subject: Req #53766 [NEW]: make RecursiveTreeIterator maintain prefix when values contain \n
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-157952@lists.php.net to get a copy of this message
From: Operating system: Linux PHP version: 5.3.5 Package: SPL related Bug Type: Feature/Change Request Bug description:make RecursiveTreeIterator maintain prefix when values contain \n Description: ------------ When printing an array using RecursiveTreeIterator, it'd be nice if it could handle new lines in the printed values without losing the tree prefix before every line after the first. Perhaps it'd make a good optional flag? Or does this option already exist but is undocumented? Test script: --------------- $array = array( 'a' => array( 'a1' => array(1, "lol\nlol\nlol", 3), 'a2' => array(3, 4, 5), ), 'b' => array( 'b1' => array(6, 7, 8), 'b2' => array(9), ), ); function print_ansi($array) { $rai = new RecursiveArrayIterator($array); $rti = new RecursiveTreeIterator($rai); $rti->setPrefixPart(0, ''); $rti->setPrefixPart(1, "\033(0\170\033(B "); $rti->setPrefixPart(2, " "); $rti->setPrefixPart(3, "\033(0\164\161\161\033(B "); $rti->setPrefixPart(4, "\033(0\155\161\161\033(B "); $rti->setPrefixPart(5, "\033(B"); foreach($rti as $value) { echo $value, PHP_EOL; } } print_ansi($array); Expected result: ---------------- ├── Array │ ├── Array │ │ ├── 1 │ │ ├── lol | | | lol | | | lol │ │ └── 3 │ └── Array │ ├── 3 │ ├── 4 │ └── 5 └── Array ├── Array │ ├── 6 │ ├── 7 │ └── 8 └── Array └── 9 Actual result: -------------- ├── Array │ ├── Array │ │ ├── 1 │ │ ├── lol lol lol │ │ └── 3 │ └── Array │ ├── 3 │ ├── 4 │ └── 5 └── Array ├── Array │ ├── 6 │ ├── 7 │ └── 8 └── Array └── 9 -- Edit bug report at http://bugs.php.net/bug.php?id=53766&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53766&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53766&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53766&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53766&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53766&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53766&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53766&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53766&r=needscript Try newer version: http://bugs.php.net/fix.php?id=53766&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53766&r=support Expected behavior: http://bugs.php.net/fix.php?id=53766&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53766&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53766&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53766&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53766&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=53766&r=dst IIS Stability: http://bugs.php.net/fix.php?id=53766&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53766&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53766&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53766&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53766&r=mysqlcfg

« previous php.bugs (#157952) next »