PHPackages                             danielstjules/sliceable-stringy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. danielstjules/sliceable-stringy

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

danielstjules/sliceable-stringy
===============================

Python string slices in PHP

1.0.0(12y ago)4751.6k2[1 PRs](https://github.com/danielstjules/SliceableStringy/pulls)1MITPHPPHP &gt;=5.4.0

Since Feb 17Pushed 9y ago3 watchersCompare

[ Source](https://github.com/danielstjules/SliceableStringy)[ Packagist](https://packagist.org/packages/danielstjules/sliceable-stringy)[ Docs](https://github.com/danielstjules/SliceableStringy)[ RSS](/packages/danielstjules-sliceable-stringy/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (1)

SliceableStringy
================

[](#sliceablestringy)

Python string slices in PHP. The class extends [Stringy](https://github.com/danielstjules/Stringy), and implements the `ArrayAccess` interface.

[![Build Status](https://camo.githubusercontent.com/30008942a1e0af69af02cf510acd122d67efc99a867b48a42588fc5f7dbe14e5/68747470733a2f2f7472617669732d63692e6f72672f64616e69656c73746a756c65732f536c69636561626c65537472696e67792e706e67)](https://travis-ci.org/danielstjules/SliceableStringy)

- [Installation](#installation)
- [Overview](#overview)
- [Examples](#examples)
- [Implementation Fidelity](#implementation-fidelity)
- [TL;DR](#tldr)

Installation
------------

[](#installation)

If you're using Composer to manage dependencies, you can include the following in your composer.json file:

```
"require": {
    "danielstjules/sliceable-stringy": "dev-master"
}

```

Then, after running `composer update` or `php composer.phar update`, you can load the class using Composer's autoloader:

```
require 'vendor/autoload.php';
```

Overview
--------

[](#overview)

`SliceableStringy` returns a slice when passed a string offset containing one or more colons. Up to 3 arguments may be passed: `'start:stop:step'`. Start, which indicates the starting index of the slice, defaults to the first character in the string if step is positive, and the last character if negative. Stop, which indicates the exclusive boundary of the range, defaults to the length of the string if step is positive, and before the first character if negative. And step allows the user to include only every nth character in the result, with its sign determining the direction in which indices are sampled.

Just like `Stringy`, `SliceableStringy` is immutable and returns a new instance with each slice.

Examples
--------

[](#examples)

```
use SliceableStringy\SliceableStringy as S;

$sliceable = S::create('Fòô Bàř', 'UTF-8');
```

#### Specific offset

[](#specific-offset)

```
$sliceable[1];    // 'ò'
$sliceable['-2']; // 'à'
```

#### Using start and stop

[](#using-start-and-stop)

```
$sliceable[':'];   // 'Fòô Bàř'
$sliceable['4:'];  // 'Bàř'
$sliceable['4:6']; // 'Bà'
```

#### Negative indices

[](#negative-indices)

```
$sliceable['-1:'];  // 'ř'
$sliceable[':-1'];  // 'Fòô Bà'
$sliceable['-3:6']; // 'Bà'
$sliceable['2:-6']; // ''
```

#### Passing a step

[](#passing-a-step)

```
$sliceable['::-1'];   // 'řàB ôòF'
$sliceable['::2'];    // 'FôBř'
$sliceable['-3::-2']; // 'BôF'
```

#### Possible exceptions

[](#possible-exceptions)

```
$sliceable[20];        // OutOfBoundsException
$sliceable['1:2:3:4']; // InvalidArgumentException, too many slice args
$sliceable['::0'];     // InvalidArgumentException, step cannot equal 0
```

Implementation Fidelity
-----------------------

[](#implementation-fidelity)

A number of specs in `spec/SliceableStringySpec.php` assert that the library mimics Python's native slice notation. On top of the handful of unit tests, `spec/fixtures/resultGenerator.py` has been used to generate test fixtures. Each of the slices in `expectedResults.csv` are checked against SliceableStringy to ensure correct functionality.

TL;DR
-----

[](#tldr)

Butchering two languages with a single library.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

2

Last Release

4514d ago

Major Versions

0.0.1 → 1.0.02014-02-19

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/817212?v=4)[Daniel St. Jules](/maintainers/danielstjules)[@danielstjules](https://github.com/danielstjules)

---

Top Contributors

[![danielstjules](https://avatars.githubusercontent.com/u/817212?v=4)](https://github.com/danielstjules "danielstjules (17 commits)")[![djmattyg007](https://avatars.githubusercontent.com/u/489338?v=4)](https://github.com/djmattyg007 "djmattyg007 (2 commits)")

---

Tags

utf-8stringutilitymanipulationpythonsliceslicing

### Embed Badge

![Health badge](/badges/danielstjules-sliceable-stringy/health.svg)

```
[![Health](https://phpackages.com/badges/danielstjules-sliceable-stringy/health.svg)](https://phpackages.com/packages/danielstjules-sliceable-stringy)
```

###  Alternatives

[danielstjules/stringy

A string manipulation library with multibyte support

2.4k26.2M192](/packages/danielstjules-stringy)[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k417.9M1.7k](/packages/nette-utils)[voku/stringy

A string manipulation library with multibyte support

1793.9M24](/packages/voku-stringy)[statamic/stringy

A string manipulation library with multibyte support, forked from @statamic

244.8M17](/packages/statamic-stringy)[voku/arrayy

Array manipulation library for PHP, called Arrayy!

4885.6M18](/packages/voku-arrayy)[tcb13/substringy

A sub string manipulation library with multibyte support that extends Stringy

1760.9k1](/packages/tcb13-substringy)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
