3v4l.org

run code in 300+ PHP versions simultaneously
<?php $updatedPapers = []; $count = 0; foreach ($this->paperList as $key => $paper) { $updatedPapers[$count] = $obj1; $count ++; if($paper->nup %2 != 0 && $paper->nup != 1){ $updatedPapers[$count] = $obj2; $count ++; } } ?> /** obj1 and obj2 get returned from a function with the below values. It seems the obj2 is overwriting obj1. obj1 ( [sheet_size_id] => 2 [sheet_size] => B1 [sheet_width] => 1020 [sheet_height] => 720 [printable_width] => 1005 [printable_height] => 704 [print_cost] => 5.69 [gsm] => 130 [thickness] => 95 [finish] => gloss [tonne_rate] => 660 [brand_name] => Chorus [brand_code] => Chorus [supplier_name] => EBBs [supplier_code] => EBBs [machine] => XL106 [machine_id] => 2 [method] => Litho [nup] => 9 [sections] => Array ( [0] => Array ( [leafs] => 2 [sheets] => 250 [method] => Work and Turn [plates] => 4 ) ) [totalPlates] => 4 [sheets] => 250 ) obj2 ( [sheet_size_id] => 2 [sheet_size] => B1 [sheet_width] => 1020 [sheet_height] => 720 [printable_width] => 1005 [printable_height] => 704 [print_cost] => 5.69 [gsm] => 130 [thickness] => 95 [finish] => gloss [tonne_rate] => 660 [brand_name] => Chorus [brand_code] => Chorus [supplier_name] => EBBs [supplier_code] => EBBs [machine] => XL106 [machine_id] => 2 [method] => Litho [nup] => 9 [sections] => Array ( [0] => Array ( [leafs] => 9 [sheets] => 223 [method] => Sheet Work [plates] => 8 ) ) [totalPlates] => 8 [sheets] => 1000 )
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Fatal error: Uncaught Error: Using $this when not in object context in /in/Vh8J9:6 Stack trace: #0 {main} thrown in /in/Vh8J9 on line 6
Process exited with code 255.

preferences:
93.12 ms | 1646 KiB | 4 Q