How to remove a number at end of a string if it is a single exam
<p>Near the top of my script below the session_start(); I have this code below:</p>

<pre><code>    if (isset($_POST['id'])) {

    $_SESSION['id'] = $_POST['id'];

    }

    if(isset($_SESSION['sessionNum'])){
                //Declare my counter for the first time

                $_SESSION['initial_session'] = $_SESSION['sessionNum'];
                $_SESSION['sessionNumber'] = intval($_SESSION['sessionNum']);
                $_SESSION['sessionCounting'] = 1;

        }

    elseif (isset($_POST['submitMarks']) &amp;&amp; $_SESSION['sessionCounting'] &lt; $_SESSION['sessionNumber']) {
        $_SESSION['sessionCounting']++;
    }

    $sessionMinus =  $_SESSION['sessionCounting'];
    $sessionConcat =  $_SESSION['sessionCounting'];


    if ($sessionMinus == $_SESSION['initial_session']){ 

        $action = 'infopenaltymarks.php'; 

    }elseif($sessionMinus != $_SESSION['initial_session']){ 

        $action = $_SERVER['PHP_SELF']; 

    }

$assessment = $_SESSION['id'] . $sessionConcat;
</code></pre>

<p>Now for the heading of the page I am using this code:</p>

<pre><code>&lt;h1&gt;INDIVIDUAL MARKS FOR EACH ANSWER: ASSESSMENT (&lt;?php echo $assessment ?&gt;) &lt;?php echo $sessionMinus ?&gt; OF &lt;?php echo $_SESSION['initial_session'] ?&gt;&lt;/h1&gt;
</code></pre>

<p>Now lets say the <code>Session</code> Table in the database looks like this below:</p>

<pre><code>SessionId  SessionName
1          AAA1
2          AAA2
3          AAB
</code></pre>

<p>Now if you look at the table above I have multiple exams <code>AAA1</code> and <code>AAA2</code> and I have a single exam <code>AAB</code>.</p>

<p>Now lets say I am working on Exam <code>AAA1</code>, it will display the heading as below:</p>

<blockquote>
  <p>INDIVIDUAL MARKS FOR EACH ANSWER: ASSESSMENT (AAA1) 1 OF 2</p>
</blockquote>

<p>The above heading is correct as it displays the correct exam name, and it states its the first out of the two <code>AAA</code> exams  </p>

<p>When I submit the page, it will change the heading to go on the second <code>AAA</code> exam which is below:</p>

<blockquote>
  <p>INDIVIDUAL MARKS FOR EACH ANSWER: ASSESSMENT (AAA2) 2 OF 2</p>
</blockquote>

<p>Again the above heading is correct.</p>

<p>The problem I have is if I have a single exam, or in this case the exam <code>AAB</code>, as it is a single exam, it does not contain a number at the end of the exam name so it is simply displayed as <code>AAB</code> in the DB.</p>

<p>But when I output the heading it displays this below:</p>

<blockquote>
  <p>INDIVIDUAL MARKS FOR EACH ANSWER: ASSESSMENT (AAB1) 1 OF 1</p>
</blockquote>

<p>Now you can see that the above heading is incorrect as it is not exam <code>AAB1</code>, it should be <code>AAB</code> in between the brackets. So what my question is that if an exam is <code>1 OF 1</code> or in other words just a single exam, how can I remove the number 1 from the end of the exam name in between the brackets so it displays it as <code>AAB</code> and not <code>AAB1</code>?</p>
