I have a string comprised of training class information for users.
I am trying to delete a substring out of that string, then return that string to the database.
I can't find any function that will strip the substring out of the string, or at least not one that would work. So I'm trying it by converting the string into an array then accepting substrings that don't match the deletion string:
Here's what I have at the moment that does NOT work:
$ClassHistory = ';Accounting Dept,Basic Accounting,0012,2008-1-18;Psychology Dept,Developmental Psychology,0148,2008-1-11;Engineering Dept,Mechanical Engineering,0404,2008-1-14';
$DelClass = ';Accounting Dept,Basic Accounting,0012,2008-1-18'
$Classes = explode(';', $ClassHistory);
$NewTranscript = '';
foreach($Classes as $Class) {
if($Class !='' AND !eregi($DelClass, $Class))
$NewTranscript .= ';'.$Class;
}
echo $NewTranscript;
What I get back is the same as the original.
I also tried preg_match, same result.
Also tried
if($Class !='' AND $DelClass != $Class)
But it also resulted in $NewTranscript being the same as $ClassHistory