: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
public function Pascal2String($pascalstring) {
// Pascal strings have 1 unsigned byte at the beginning saying how many chars (1-255) are in the string
return substr($pascalstring, 1);
* @param string $pascalstring
public function MaybePascal2String($pascalstring) {
// Pascal strings have 1 unsigned byte at the beginning saying how many chars (1-255) are in the string
// Check if string actually is in this format or written incorrectly, straight string, or null-terminated string
if (ord(substr($pascalstring, 0, 1)) == (strlen($pascalstring) - 1)) {
return substr($pascalstring, 1);
} elseif (substr($pascalstring, -1, 1) == "\x00") {
// appears to be null-terminated instead of Pascal-style
return substr($pascalstring, 0, -1);
* Helper functions for m4b audiobook chapters
* code by Steffen Hartmann 2015-Nov-08.
public function search_tag_by_key($info, $tag, $history, &$result) {
foreach ($info as $key => $value) {
$key_history = $history.'/'.$key;
$result[] = array($key_history, $info);
$this->search_tag_by_key($value, $tag, $key_history, $result);
public function search_tag_by_pair($info, $k, $v, $history, &$result) {
foreach ($info as $key => $value) {
$key_history = $history.'/'.$key;
if (($key === $k) && ($value === $v)) {
$result[] = array($key_history, $info);
$this->search_tag_by_pair($value, $k, $v, $key_history, $result);
public function quicktime_time_to_sample_table($info) {
$this->search_tag_by_pair($info['quicktime']['moov'], 'name', 'stbl', 'quicktime/moov', $res);
foreach ($res as $value) {
$this->search_tag_by_pair($value[1], 'data_format', 'text', $value[0], $stbl_res);
if (count($stbl_res) > 0) {
$this->search_tag_by_key($value[1], 'time_to_sample_table', $value[0], $stts_res);
if (count($stts_res) > 0) {
return $stts_res[0][1]['time_to_sample_table'];
public function quicktime_bookmark_time_scale($info) {
$this->search_tag_by_pair($info['quicktime']['moov'], 'name', 'stbl', 'quicktime/moov', $res);
foreach ($res as $value) {
$this->search_tag_by_pair($value[1], 'data_format', 'text', $value[0], $stbl_res);
if (count($stbl_res) > 0) {
$this->search_tag_by_key($info['quicktime']['moov'], 'time_scale', 'quicktime/moov', $ts_res);
foreach ($ts_res as $sub_value) {
$prefix = substr($sub_value[0], 0, -12);
if ((substr($stbl_res[0][0], 0, strlen($prefix)) === $prefix) && ($ts_prefix_len < strlen($prefix))) {
$time_scale = $sub_value[1]['time_scale'];
$ts_prefix_len = strlen($prefix);
// END helper functions for m4b audiobook chapters