PHP code example of azandazama / menuplus

1. Go to this page and download the library: Download azandazama/menuplus 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/ */

    

azandazama / menuplus example snippets


$ussd->title = 'Welcome to the Example Ussd Platform!';
$ussd->options = ['Option 1', 'Option 2', 'Option 3'];
$ussd->option_url = ['index.php?page=1', 'index.php?page=2', 'index.php?page=3'];
echo $ussd->addMenu($url);

$ussd->title = 'Please provide first and last name';
$ussd->option_url = 'index.php?file=4';
echo $ussd->addMenu($url);

$ussd->title = 'Select an option';
$ussd->options = ['Option 1', 'Option 2', 'Option 3', 'Option 4', 'Option 5', 'Option 6', 'Option 7'];
// Menu options can all share the same url
$ussd->option_url = 'index.php?page=5';
// [3] is the amount of options that will be shown in this menu
return $ussd->paginateMenu($url, 3);


d = new \MenuPlus\Ussd;
// ensure your url ends with a backslash
$url = 'http://localhost:7000/';

function initMenu($ussd, $url)
{
    switch(@$_GET['page'])
    {
        case '':
            // This is the first menu the application will serve
            $ussd->title = 'Welcome to the Example Ussd Platform!';
            $ussd->options = ['Questionnaire', 'Register', 'Shows available', 'Exit'];
            $ussd->option_url = ['index.php?page=1', 'index.php?page=2', 'index.php?page=3', 'index.php?page=4', 'index.php?page=exit'];
            return $ussd->addMenu($url);
        break;
        case 1: 
            $ussd->title = 'What year was Nelson Mandela born';
            $ussd->options = ['1900', '1918', 'Back'];
            $ussd->option_url = ['index.php?page=answer&ans=wrong', 'index.php?page=answer&ans=correct', 'index.php'];
            return $ussd->addMenu($url);
        break;
        case 2:
            // FreeText Menu's have no options just one title and url
            $ussd->title = 'Please provide first and last name';
            $ussd->option_url = 'index.php?file=names';
            return $ussd->addMenu($url);
        break;
        case 3:
            $ussd->title = 'Select your favourite TV show';
            $ussd->options = ['The Simpsons', 'Star Wars', 'Peanuts', 'South Park',
            'Courage the Cowardly Dog', 'Avatar: The Last Airbender',
            'Dexters Laboratory', 'Futurama', 'The Jetsons', 'Phineas and Ferb',
            'Kim Possible', 'Samurai Jack', 'Dora the Explorer'];
            // Menu options can all share the same url
            $ussd->option_url = 'index.php?page=shows';
            // [5] is the amount of options that will be shown per menu
            return $ussd->paginateMenu($url, 5);
        break;
        case 'exit': 
            $ussd->title = "Thank you!\nUssd Platform";
            return $ussd->addMenu($url);
        break;
    }
}

echo initMenu($ussd, $url);