Git Product home page Git Product logo

ustring's Introduction

Usage

$ustr = new UString('Üzüm üzüm', 'UTF-8');

print $ustr; // Üzüm üzüm
print $ustr->toLower(); // üzüm üzüm

Methods

set()

$ustr->set('New string!');

get()

print $ustr->get(); // Üzüm üzüm

toLower()

print $ustr->toLower(); // üzüm üzüm

toUpper()

print $ustr->toUpper(); // ÜZÜM ÜZÜM

toTitle()

print $ustr->toTitle(); // Üzüm Üzüm

slugify()

print $ustr->slugify(); // uzum-uzum
print $ustr->slugify(false); // Uzum-uzum

toLowerFirst()

print $ustr->toLowerFirst(); // üzüm üzüm

toUpperFirst()

print $ustr->toUpperFirst(); // Üzüm üzüm

toLowerWords()

print $ustr->toLowerWords(); // üzüm üzüm

toUpperWords()

print $ustr->toUpperWords(); // Üzüm Üzüm

first()

print $ustr->first(); // Ü

last()

print $ustr->last(); // m

nth()

print $ustr->nth(); // m

firstCharIs()

print $ustr->firstCharIs('Ü'); // true

lastCharIs()

print $ustr->lastCharIs('m'); // true

nthCharIs()

print $ustr->nthCharIs(2, 'ü'); // true

shift()

print $ustr->shift(); // Ü
print $ustr->shift(); // z
print $ustr->get(); // üm üzüm

pop()

print $ustr->pop(); // m
print $ustr->pop(); // ü
print $ustr->get(); // Üzüm üz

reverse()

print $ustr->reverse();
print $ustr->get(); // müzü müzÜ

shuffle()

print $ustr->shuffle();
print $ustr->get(); // zü ümüzÜm

substring()

print $ustr->substring(1);
print $ustr->substring(-1);
print $ustr->substring(-5);
print $ustr->substring(-5, 1);
print $ustr->substring(0, 1);
print $ustr->substring(0, -1);
print $ustr->substring(-3, -1);

countSubstring()

print $ustr->countSubstring('ü', true);     // 3 (case-sensitive)
print $ustr->countSubstring('ü', false);    // 4 (no case-sensitive)
print $ustr->countSubstring('ü', false, 3); // 2 (no case-sensitive, start 3th chr offset)

countChars()

print $ustr->countChars('ü');   // 3, frequency of "ü" (int)
print $ustr->countChars(false); // 5, count of uniq chars (int)
print $ustr->countChars(true);  // all chars with own frequencies (array)
/*
Array
(
    [Ü] => 1
    [z] => 2
    [ü] => 3
    [m] => 2
    [ ] => 1
)
*/

length()

print $ustr->length(); // 9

position() positionLeft() positionRight()

print $ustr->position('ü');        // 2
print $ustr->position('ü', false); // 0 (no case-sensitive)
print $ustr->positionLeft('ü');    // 2 (alias of position)
print $ustr->positionRight('ü');   // 7

charAt()

print $ustr->charAt(0); // Ü (alias of nth)

match()

print $ustr->match('~(ü)~'); // 1

$ustr->match('~(ü)~', $ms);
print_r($ms); // array(...)

random()

print $ustr->random();  // m
print $ustr->random(3); // zmÜ

append()

$ustr->append('...');
print $ustr->get() // Üzüm üzüm...

prepend()

$ustr->prepend('...');
print $ustr->get() // ...Üzüm üzüm

surround()

$ustr->surround('|');
print $ustr->get() // |Üzüm üzüm|

strip() stripLeft() stripRight()

$ustr->strip('Üüm');
print $ustr->get() // züm üz
$ustr->stripLeft('Ü');
print $ustr->get() // züm üzüm
$ustr->stripRight('üm');
print $ustr->get() // Üzüm üz

replace()

print $ustr->replace('ü', 'u');
print $ustr->replace(array('Ü', 'ü'), '...');
print $ustr->replace(array('Ü', 'ü'), array('U', 'u'));

translate()

print $ustr->translate('Üüm', 'Uu-');        // Uzu- uzu-
print $ustr->translate(array('z' => '@')); // Ü@üm ü@üm

chunk()

print $ustr->chunk(3); // array(...)

split()

print $ustr->split(); // array(...)

stringify()

print $ustr->stringify(); // Üzüm üzüm

isASCII()

print $ustr->isASCII(); // false (Üzüm üzüm)

$ustr->set('Hello PHP!');
print $ustr->isASCII(); // true

ustring's People

Contributors

krmgns avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.