Script issue moving to php 7.2 - RESOLVED

Okay I found the last issue but now need help. I am trying to get my site off of php 5.6 and move to 7.2. My JPGraph program needed to be upgraded which I have done and now at 4.2.6. The script below runs on php 5.6 perfectly now but will not run on php 7.2. The jpgraph 4.2.6 is supposed to support both.

Can someone look at the script below and tell me if you see anything that is depreciated etc. that would cause the graph to not display
Errors reported when domain is set to php7.2:

Fatal error: Uncaught TypeError: Argument 1 passed to JpGraphException::defaultHandler() must be an instance of Exception, instance of Error given in /home/auburnwe/public_html/jp/src/jpgraph_errhandler.inc.php:158 Stack trace: #0 [internal function]: JpGraphException::defaultHandler(Object(Error)) #1 {main} thrown in /home/auburnwe/public_html/jp/src/jpgraph_errhandler.inc.php on line 158

<?php
//where are your clientraw*-files relative to where this file is
$hostloc = "./";
date_default_timezone_set('America/Halifax');
include ("jp/src/jpgraph.php");           //maybe you have to change this path
include ("jp/src/jpgraph_line.php");       //maybe you have to change this path

// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);


// CtoF: converts degrees Celcius to degress Farenheight
function CtoF(&$value) {
  return round($value = ((1.8* $value) + 32),1);
} // end function C_to_F

// Create the graph and specify the scale for Y-axis
$graph = new Graph(400,250,"auto",30);    
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->SetMarginColor("#191970");
$graph->img->SetAntiAliasing();

$url = "http://www.auburnweatherlive.com/atticdatapull.php";   // this is the page where you get the information
$str = file_get_contents($url);                                // retrieve the content of the page. This results in one single string with all the content

$str = ereg_replace(" 
","","$str");
$str = ereg_replace("X_Axis = ","","$str");                   
$str = ereg_replace("Y_Axis = ","xx","$str");

$data = explode("xx", $str);                                   // xx is the separator. You will get two strings in $data
$x = $data[0];                                                 // first part of $data is the X_Axis data
$y = $data[1];                                                 // second part of $data is the Y_Axis data

$datat = explode(" ", $x);                                     // make an array of $x 
$ydata = explode(" ", $y);                                     // make an array of $y

//create timearray for the x-axis
$n=1;
$limit=26;
putenv('TZ=America/Halifax');
$time=date(" H",time());
$datat=array($time);
$x=$datat;
//what you have to add
$add=3600;
$result=strtotime(now);
for ($n=1;$n++;)
{
$result=($result-$add);
$new=date('ga', $result);
$next=array("$new");
$datat= array_merge ($next,$datat);
if ($n>=$limit) break;
  }
$datat=array_merge($datat,$x);

// =====================================================================================
// From here we start creating the graphs
// =====================================================================================

// Adjust the margin
$graph->img->SetMargin(40,40,20,65);

// Create the two linear plot
$lineplot=new LinePlot($ydata);

// Add the plot to the graph
$graph->Add($lineplot);

//titles
$graph->title->Set("Attic");
$graph->title->SetFont(FF_FONT1,FS_BOLD,10);
$graph->title->SetColor("royalblue4");
//$graph->xaxis->title->Set("X-title");
//$graph->yaxis->title->Set("Y-title");

//x-axis
//$graph->xaxis->title->Set("X-title");
$time=date("M j",time());
$graph->xaxis->title->Set($time);
$graph->xaxis->title->SetColor(royalblue4);
$graph->xaxis->SetFont(FF_FONT1,FS_NORMAL,4);
$graph->xaxis->SetTickLabels($datat); 
$graph->xaxis->SetTextLabelInterval(3);
$graph->xaxis->SetPos("min"); 
$graph->xaxis->SetColor("royalblue4"); 
$graph->xaxis->HideTicks(true,true); 
$graph->xgrid->Show(true);

//y-axis
$graph->yaxis->SetColor("royalblue4");
$graph->yaxis->SetLabelFormat('%0.0f

Resolved from another forum.

It is your use of ereg_replace that is causing the failure. It was deprecated in PHP 5.3 and removed in PHP 7.0. preg_replace is the recommend alternative. Based on what those statements are doing though you may be able to use str_replace instead of preg_replace.

For completeness a single call to str_replace should be able to replace those ereg_replace calls if I