I just want to ask if it is possible to construct a class in PHP that returns an array when print_red
For example:
<?php
$c = new class(1,2,3){
function __construct($var1, $var2, $var3){
$this->value = [$var1 => [$var2, $var3]];
}
};
print_r((array) $c);
i want it to result in:
Array ( [1] => Array ( [0] => 2 [1] => 3 ) )
instead i get
Array ( [value] => Array ( [1] => Array ( [0] => 2 [1] => 3 ) ) )
print_r()is a function used for debug. It shouldn't matter how its output looks like. Why is it that important to you? I suspect you are trying to solve a different problem.print_rto explain the result