PHP code example of worthwelle / alphonic

1. Go to this page and download the library: Download worthwelle/alphonic library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

worthwelle / alphonic example snippets




$alphonic = new Alphonic();
$alphonic->load_alphabets();
$alphonic->alphabet("NATO")->add_symbol(" ","|");
$alphonic->alphabet("NATO")->add_symbol(",","Comma");
$alphonic->alphabet("NATO")->add_symbol("!","Exclamation");

echo $output = $alphonic->phonetify("Holy alphabets, Batman!", "NATO");
// Hotel Oscar Lima Yankee | Alfa Lima Papa Hotel Alfa Bravo Echo Tango Sierra Comma | Bravo Alfa Tango Mike Alfa November Exclamation
echo $alphonic->unphonetify($output, "NATO");
// HOLY ALPHABETS, BATMAN!



$alphonic = new Alphonic();
$alphonic->load_alphabet_from_file('myalphabet.json');
$alphonic->load_alphabet_from_json(file_get_contents('myotheralphabet.json');

// The second argument allows Alphonic to skip alphabets that don't pass validation.
// This defaults to false.
$alphonic2 = new Alphonic('directory/full/of/alphabets', true);