<?php
$content = file_get_contents('index.php');

$search = "\$_SESSION['outlet_id'] = \$u['outlet_id'];";
$replacement = "\$_SESSION['outlet_id'] = \$u['outlet_id'];";

// To fix duplicates, we can simply replace 3 of them with 1
$content = preg_replace("/(\s*\\\$_\SESSION\['outlet_id'\] = \\\$u\['outlet_id'\];){2,}/", "\n        \$_SESSION['outlet_id'] = \$u['outlet_id'];", $content);

file_put_contents('index.php', $content);
echo "Duplicate login outlet_ids removed.\n";
