Skip to content

v1.12 #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 18, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
update Readme with example code
  • Loading branch information
JBlond committed Feb 22, 2019
commit 3396d355780cb6dec0dd85d7eccc9933c15e3f40
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,36 @@ composer require jblond/php-diff

## Example Use

```PHP
<?php
// installed via composer
require 'vendor/autoload.php';

// or installed manual
require dirname(__FILE__).'/../lib/Autoloader.php';
new \jblond\Autoloader();

$a = explode("\n", file_get_contents(dirname(__FILE__).'/a.txt'));
$b = explode("\n", file_get_contents(dirname(__FILE__).'/b.txt'));
// Options for generating the diff
$options = array(
//'ignoreWhitespace' => true,
//'ignoreCase' => true,
);
// Initialize the diff class
$diff = new \jblond\Diff($a, $b, $options);

//choose renderer
$renderer = new \jblond\Diff\Renderer\Html\SideBySide(array(
'title_a' => 'Custom title for OLD version',
'title_b' => 'Custom title for NEW version',
));

//show it
echo $diff->Render($renderer);
```

### Example Output
A quick usage example can be found in the example/ directory and under
example.php.

Expand Down