function treffynnon_mandelbrot_to_mem($w, $h, $binary_output) { $file_open_type = 'w+'; if ($binary_output) { $file_open_type = 'w+b'; } $stream = fopen('php://memory', $file_open_type); if (false === $stream) { return ''; } write_mandelbrot_to_stream((int) $w, (int) $h, $stream, (bool) $binary_output); rewind($stream); $ret = stream_get_contents($stream); fclose($stream); return $ret; }
function treffynnon_mandelbrot_to_mem($w, $h, $binary_output) { ob_start(); write_mandelbrot_to_stream((int) $w, (int) $h, (bool) $binary_output); return ob_get_clean(); }