2017 © Pedro Peláez
 

library string-diff

A class to extract variables in identically formatted string with only small differences

image

rasmusrosengren/string-diff

A class to extract variables in identically formatted string with only small differences

  • Sunday, September 4, 2016
  • by rasmusrosengren
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

StringDiff

StringDiff is a small plugin that allows easy manipulation of similarly formatted strings, with very small differences at same places., (*1)

Usage

new StringDiff
$stringd = new StringDiff;

$test_array = [
    "Your Cooldown Reduction cap is increased to 41% and you gain 1% Cooldown Reduction",
    "Your Cooldown Reduction cap is increased to 42% and you gain 2% Cooldown Reduction",
    "Your Cooldown Reduction cap is increased to 43% and you gain 3% Cooldown Reduction",
    "Your Cooldown Reduction cap is increased to 44% and you gain 4% Cooldown Reduction",
    "Your Cooldown Reduction cap is increased to 45% and you gain 5% Cooldown Reduction",
];

$stringd->run($test_array);
foreach($stringd->getArgs() as $arg)
{
    echo vsprintf($stringd->getUnformattedString(), $arg) . '<br>';
}

The run(array $arr) method processes the array of data and outputs the unformatted string and an array of arguments, the unformatted string contains %s which in turns are replaces by the arguments using vsprintf($unformatted string, array $args) after manipulation., (*2)

The getUnformattedString() method returns the unformatted string which contains the %s placeholders., (*3)

The getArgs() returns an array of arguments formatted as following:, (*4)

0 => [
    0 => 41
    1 => 1
],
1 => [
  0 => 42,
  1 => 2
]
...

The Versions

04/09 2016

dev-master

9999999-dev

A class to extract variables in identically formatted string with only small differences

  Sources   Download

MIT

The Requires

  • php 5.6.*

 

07/08 2016

1.0.0

1.0.0.0

A class to extract variables in identically formatted string with only small differences

  Sources   Download

MIT

The Requires

  • php 5.6.*