D
D
Deefs2018-02-04 17:27:55
PHP
Deefs, 2018-02-04 17:27:55

Instead of a link to an audio player?

Good afternoon, there are audio comments on the site, when you add it, the path to the audio comment appears in the form
[audio records/1517754431.wav]

how can I make the player show instead of text?
please help folks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
John Doe, 2018-02-04
@rabbit418

For example:

<?php
function parseAudio($message) {
  $matches = [];
  $s = preg_match('/\[audio (.*?)\]/', $message, $matches);
  return str_replace($matches[0], "<audio controls><source src=\"{$matches[1]}\" type=\"audio/wav\"></audio>", $message);
}

echo parseAudio("Message with audio\n[audio records/1517754431.wav]");
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question