function encodeWav(array $raw) : array
{
$result = "RIFF"
. pack('V', count($raw))
. "WAVEfmt "
. pack('V', 16)
. pack('v', 1)
. pack('v', TTS_DEFAULT_OPTIONS['numChannels'])
. pack('V', TTS_DEFAULT_OPTIONS['sampleRate'])
. pack('V', TTS_DEFAULT_OPTIONS['sampleRate'] * 4)
. pack('v', 4)
. pack('v', 16)
. 'data'
. pack('V', count($raw) * 2);
$volume = 1;
foreach ($raw as $unit) {
$result .= pack('v', $unit * $volume);
}
return [
'type' => 'audio/x-wav',
'content' => $result
];
}
print preg_replace('/https:\/\/site.com\/([^\s]*)a.jpg/U','https://site.com/$1b.jpg', 'https://site.com/testa.jpg');
// https://site.com/testb.jpg
print preg_replace('/https:\/\/site.com\/([^\s]*)a.jpg/U','https://site.com/$1b.jpg', 'https://site.com/testA.jpg');
// https://site.com/testA.jpg
trait Harvestable {
function harvest() { }
}
trait Waterable {
function water() { }
}
trait Repottable {
function repot() { }
};
class Plant { }
class Vegetable extends Plant {
use Waterable;
use Harvestable;
}
class Fruit extends Plant {
use Waterable;
use Harvestable;
use Repottable;
}
class Succulent extends Plant {
use Repottable;
}