alex
unread,Oct 16, 2020, 7:04:03 AM10/16/20Sign in to reply to author
Sign in to forward
Sign in to report message as abuse
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
// DESIGN 1
echo "Non funziona, ma mi piace il 'DESIGN 1' ";
$arr = [1, 2];
print_r(
array_shift($arr)
);
// DESIGN 2
echo "Funziona, ma non mi piace il 'DESIGN 2': ";
$arr = [1, 2];
array_shift($arr);
print_r(
$arr
);
Output:
Non funziona, ma mi piace il 'DESIGN 1': 1
Funziona, ma non mi piace il 'DESIGN 2': Array
(
[0] => 2
)
Per trovare un compromesso mi son creato questa classe:
<?php
class FirstProcessedArgumentReturn {
static function __callStatic(string $name, array $arguments) {
$name($arguments);
return $arguments[0];
}
}
FirstProcessedArgumentReturn::array_shift([1, 2]);
//TODO: Test the method FirstProcessedArgumentReturn::array_push(...);
//TODO: Test the method FirstProcessedArgumentReturn::array_pop(...);
//TODO: Test the method ...
PHP Notice: Undefined offset: 0 in /tmp/test.php on line 6
Ma come vedete qualcosa non funziona: il motivo lo lascio immaginare.
Qualche idea?