1. Go to this page and download the library: Download malenki/bah 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/ */
malenki / bah example snippets
$greek = new S('Τα ελληνικά σου είναι καλύτερα απο τα Γαλλικά μου!');
echo $greek; // 'Τα ελληνικά σου είναι καλύτερα απο τα Γαλλικά μου!'
echo $greek->upper; // ΤΑ ΕΛΛΗΝΙΚΆ ΣΟΥ ΕΊΝΑΙ ΚΑΛΎΤΕΡΑ ΑΠΟ ΤΑ ΓΑΛΛΙΚΆ ΜΟΥ!
echo $greek->lower; // τα ελληνικά σου είναι καλύτερα απο τα γαλλικά μου!
echo $greek->title; // Τα Ελληνικά Σου Είναι Καλύτερα Απο Τα Γαλλικά Μου!
echo $greek->title->swap; // τΑ εΛΛΗΝΙΚΆ σΟΥ εΊΝΑΙ κΑΛΎΤΕΡΑ αΠΟ τΑ γΑΛΛΙΚΆ μΟΥ!
$s = new S('azzertyy');
echo $s->squeeze; // azerty
$s = new S('aaazzertyy');
echo $s->squeeze('za'); // azertyy
echo $greek->sub(4)->n;
echo $greek->chars->length->to_s->n;
echo $greek->bytes->length->to_s->n;
$long = new S('Put a very long string here…');
echo $long->wrap(20)->n->n;
echo $long->wrap(30)->n->n;
echo $long->wrap(40)->n->n;
echo $long->wrap(80)->n->n;
echo $long->wrap(80)->ucw->n->n; // with upper case words
echo 'First: ';
// margin left 10 chars length, right 0, first -7 to place the previous string "First: "
echo $long->wrap(40)->margin(10, 0, -7)->n->n;
echo $long->wrap(40)->margin(10)->n->n; // same as previous, but only left margin
$s = new S('Τα ελληνικά σου είναι καλύτερα απο τα Γαλλικά μου!');
echo $s->trans->n; // Ta ellenika sou einai kalytera apo ta Gallika mou!
$s = new S('Ceci est du français tout à fait banal.');
var_dump($s->ltr); // true
var_dump($s->is_ltr); // true
var_dump($s->is_left_to_right); // true
var_dump($s->left_to_right); // true
$s = new S('Ceci est du français contenant le mot arabe أبجد qui veut dire "abjad".');
var_dump($s->has_mixed_direction); // true
var_dump($s->mixed_direction); // true
var_dump($s->is_ltr_and_rtl); // true
var_dump($s->ltr_and_rtl); // true
var_dump($s->is_rtl_and_ltr); // true
var_dump($s->rtl_and_ltr); // true
$s = new S('Foo');
echo $s->tag('p strong.bar'); // '<p><strong class="bar">Foo</strong></p>'
$c = new C("€");
while($c->bytes->valid())
{
// for each bytes, print it as binary string and add new line
echo $c->bytes->current()->b->n;
$c->bytes->next();
}
$a = new A(array('un', 'deux', 'trois', 'quatre'));
var_dump(count($a));
var_dump($a->last_but_one);
$a = new A(array('zéro', 'un', 'deux', 'trois', 'quatre'));
echo $a->take(2); // 'deux'
// or
echo $a->index_2;
// or
echo $a->key_2;
$a = new A(array('un', 'deux', 'trois', 'quatre'));
var_dump($a->shuffle); //randomize
var_dump($a->sort); //sort ascendently
var_dump($a->reverse); //reverse order
var_dump($a->sort->reverse); // sort and then reverse it
$a = new A(array('foo', 'bar', 'thing', 'other'));
$a->find('>= 2'); // has 'thing' and 'other'
$a->find('odd'); // has 'bar' and 'other'
$a = new A(array('un', 'deux', 'trois', 'quatre'));
var_dump($a->random);
// or
var_dump($a->random(1));
$a = new A(array('un', 'deux', 'trois', 'quatre'));
var_dump($a->random(2));
$a = new A(array('un', 'deux', 'trois', 'quatre'));
var_dump($a->join);
//or
var_dump($a->implode);
$a = new A(array('un', 'deux', 'trois', 'quatre'));
while($a->valid) // you can use method call too
{
echo $a->current . "\n";
$a->next;
}
$five = new N(5);
$two = new N(2);
echo $five->plus(2); // native number or N object
echo $five->minus($two);
echo $five->divide(2);
$five = new N(5);
$two = new N(2);
var_dump($two->minus($five)->negative); //should be true
var_dump($two->minus(2)->zero); //should be true
var_dump($two->positive); //should be true
$n = new N(1979);
echo $n->base(2); // get "11110111011"
echo $n->base(3); // get "2201022"
echo $n->base(34); // get "1o7"
$n = new N(1979);
// binary
echo $n->bin;
// or
echo $n->b;
// octal
echo $n->oct;
// or
echo $n->o;
// hexadecimal
echo $n->hex;
// or
echo $n->h;
$n = new N(3);
var_dump($n->odd);
var_dump($n->even);
$n = new N(4);
var_dump($n->odd);
var_dump($n->even);
$n = new N(4.3);
var_dump($n->decimal); // N object having 0.3 as value
$five = new N(5);
print($five->roman);
print($five->greek);
$n = new N(123456); // will be '十二兆三千四百五十六'
echo $n->chinese();
// or
echo $n->chinese;
// or
echo $n->mandarin;
// or
echo $n->putonghua;
$n = new N(16.98); // Will be '十六点九八'
echo $n->chinese;
$n = new N(-16.98); // Will be '负十六点九八'
echo $n->chinese;
$n = new N(208);
echo $n->chinese(true); // Will be '二百〇八'
echo $n->chinese_other_zero; // Will be '二百〇八'
echo $n->mandarin_other_zero; // Will be '二百〇八'
echo $n->putonghua_other_zero; // Will be '二百〇八'
// but:
echo $n->chinese(); // Will be '二百零八'
echo $n->chinese; // Will be '二百零八'
echo $n->mandarin; // Will be '二百零八'
echo $n->putonghua; // Will be '二百零八'
$h = new H();
$h->set('my_key', 'My Value');
// or
$y->my_key = 'My Value';