Skip to content

Instantly share code, notes, and snippets.

View Rapkalin's full-sized avatar
🏠
Working from home

Raphael Rapkalin

🏠
Working from home
View GitHub Profile
@Rapkalin
Rapkalin / php-8.1-strftime.php
Created September 27, 2024 14:55 — forked from bohwaz/php-8.1-strftime.php
strftime() replacement function for PHP 8.1
<?php
namespace PHP81_BC;
/**
* Locale-formatted strftime using \IntlDateFormatter (PHP 8.1 compatible)
* This provides a cross-platform alternative to strftime() for when it will be removed from PHP.
* Note that output can be slightly different between libc sprintf and this function as it is using ICU.
*
* Usage:
* use function \PHP81_BC\strftime;
@Rapkalin
Rapkalin / previewSql.php
Last active August 6, 2023 19:15
Preview SQL query with Laravel
<?php
Function previewSql()
{
$users = User::where(‘id’, 0);
$users->union(User::where(‘id’, 1));
$users->union(User::where(‘id’, 2));
$users->union(User::where(‘id’, 3));
// Preview sql statement using getBindings() and toSql() builder methods
@Rapkalin
Rapkalin / PHP - Move given value to the end of an array
Last active October 21, 2022 14:46
PHP function to move a searched value to the end of an array
public static function moveValueToTheEnd(array $array, $searchedValue) : array
{
dump('initial array', $array);
$j = 0;
for ($i = 0; $i < (count($array)); $i++) {
if ($array[$i] === $searchedValue && isset($array[$i + 1])) {
$array[$i] = $array[$i + 1];
$array[$i + 1] = $searchedValue;