3v4l.org

run code in 300+ PHP versions simultaneously
<?php class PO { public $entries = array( "1\n", "a\n\n" ); public static function export_entry( &$entry ) { return trim($entry); } function export_entriesA() { return implode( "\n\n", array_map( array( 'PO', 'export_entry' ), $this->entries ) ); } function export_entriesB() { array_walk( $this->entries, array( 'PO', 'export_entry' ) ); return implode( "\n\n", $this->entries ); } function export_entriesC() { $entries = $this->entries; array_walk( $this->entries, array( 'PO', 'export_entry' ) ); return implode( "\n\n", $entries ); } } $obj = new PO(); var_dump($obj->export_entriesA()); var_dump($obj->entries); var_dump($obj->export_entriesC()); var_dump($obj->entries); var_dump($obj->export_entriesB()); var_dump($obj->entries);

preferences:
59.34 ms | 402 KiB | 5 Q