Skip to content

Instantly share code, notes, and snippets.

@ozh
ozh / example.php
Last active July 26, 2022 11:55 — forked from sobi3ch/gist:5451004
PHP Array pluck function
<?php
$foods = array(
array(
'id' => 4,
'name' => 'Banana',
'color' => 'Yellow',
),
array(
'id' => '5',
'name' => 'Apple',
@PeterJuel
PeterJuel / gist:2634518
Created May 8, 2012 12:15
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");
@mrkmg
mrkmg / genColorCodeFromText.php
Created January 13, 2012 17:22
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)