Skip to content

Instantly share code, notes, and snippets.

@osazeblogger
osazeblogger / example.php
Created April 25, 2022 15:43 — forked from ozh/example.php
PHP Array pluck function
<?php
$foods = array(
array(
'id' => 4,
'name' => 'Banana',
'color' => 'Yellow',
),
array(
'id' => '5',
'name' => 'Apple',
@osazeblogger
osazeblogger / gist:3503773edbc9807f03b5f19fd61f3273
Created January 22, 2022 23:35 — forked from PeterJuel/gist:2634518
PHP: Import huge SQL file to MySQL
$mysqli = new mysqli('localhost', '#username', '#password', '#database');
$handle = fopen('sqldump.sql', 'rb');
if ($handle) {
while (!feof($handle)) {
// This assumes you don't have a row that is > 1MB (1000000)
// which is unlikely given the size of your DB
// Note that it has a DIRECT effect on your scripts memory
// usage.
$buffer = stream_get_line($handle, 1000000, ";\n");
@osazeblogger
osazeblogger / url_slug.php
Created December 19, 2021 00:06 — forked from sgmurphy/url_slug.php
URL Slugs in PHP (with UTF-8 and Transliteration Support)
<?php
/**
* Create a web friendly URL slug from a string.
*
* Although supported, transliteration is discouraged because
* 1) most web browsers support UTF-8 characters in URLs
* 2) transliteration causes a loss of information
*
* @author Sean Murphy <[email protected]>
* @copyright Copyright 2012 Sean Murphy. All rights reserved.
@osazeblogger
osazeblogger / genColorCodeFromText.php
Created December 9, 2021 03:24 — forked from mrkmg/genColorCodeFromText.php
Generate a unique color based on text input
<?php
/*
* Outputs a color (#000000) based Text input
*
* @param $text String of text
* @param $min_brightness Integer between 0 and 100
* @param $spec Integer between 2-10, determines how unique each color will be
*/
function genColorCodeFromText($text,$min_brightness=100,$spec=10)