Skip to content

Instantly share code, notes, and snippets.

View abraunton's full-sized avatar

Alex Braunton abraunton

View GitHub Profile
@abraunton
abraunton / showdifferences.php
Last active December 30, 2015 00:49
This is a simple PHP function that compares two strings and returns the differences in red. Call the function by using showdifferences("string one", "string two"). This will then show the original string but with the new changes in red and bold.
function showdifference($string1, $string2) {
// Both strings are split up by spaces, each word is now an item in an array.
$string1_array = explode(" ", $string1);
$string2_array = explode(" ", $string2);
// We will count both arrays to see which is the largest (used later).
$s1_count = count($string1_array);
$s2_count = count($string2_array);