spatie / string Goto Github PK
View Code? Open in Web Editor NEWString handling evolved
Home Page: https://murze.be/2015/06/common-string-functions/
License: MIT License
String handling evolved
Home Page: https://murze.be/2015/06/common-string-functions/
License: MIT License
Why in description of method SEGMENT has two parameters, but one of the examples has three parameters? "->segment('/', 0, true)"
Method description:
/**
* Get a segment from a string based on a delimiter.
* Returns an empty string when the offset doesn't exist.
* Use a negative index to start counting from the last element.
*
* @param string $delimiter
* @param int $index
*
* @return \Spatie\String\String
*/
public function segment($delimiter, $index) <-- 2 parameters
Example:
string('foo/bar/baz')->segment('/', 0, true); // baz <-- 3 parameters
Why do not use:
string('foo/bar/baz')->segment('/', -1); // baz
Hi,
Would it be a good idea to return $this
from the explode
and provide the possibility to use array_filter
or array_map
and other native feature on the array or simply a callback for the user defined action.
Usecase:
I have a string say
$sizeStr = "Nice shoes with Size= 12 ,13, 14 , 15, ";
$filterCallback= function($item){
return true; // just example
};
$parsedSize = \string($sizeStr)
->lastSegment('Size=')
->trim()
->explode(',')
->arrayFilter()
->arrayMap('trim')
->apply(function($data){
});
Would something like this be useful ?
Package anahkiasen/underscore-php is abandoned, you should avoid using it. No replacement was suggested.
Create a function 'replaceFirst' string.
This package has a dependency from an abandoned package
Sample code for replaceFirst https://github.com/spatie/string#replacefirst are not match. It show the sample code for replaceLast. I tough it switched, but replaceLast are good. Care if i fix it?
Hello,
It would be nice to have startsWith()
and endsWith()
methods.
http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php
Are pull requests welcome?
I have started to receive warnings from composer that anahkiasen/underscore-php is now abandoned. No alternative for this package is provided, however Laravel's Str:: helpers provide some alternative functions.
It may be worth removing this dependency and directing people towards the Laravel helpers in the Illuminate\Support package?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.