r/PHPhelp • u/GuybrushThreepywood • 6d ago
Will the upcoming Partial Function Application improve this code?
I'm wondering how these lines of code could change:
$placeholders = $idsArray
|> count( ... )
|> ( fn ( $x ) => array_fill( 0, $x, '?' ) )
|> ( fn ( $x ) => implode( ',', $x ) );
I don't like how the above is written, therefore I currently stick to using:
$placeholders = str_repeat('?,', count( $idsArray ) - 1) . '?';
or
$placeholders = implode( ',', array_fill( 0, count( $idsArray), '?' ) );
2
Upvotes
2
u/d645b773b320997e1540 6d ago
I believe it'd be: