Jump to content

[SOLVED] adding 1 to alphanumeric value


Walker33

Recommended Posts

I have a column that contains a string, for example, R01,R02,R03,R04,S01,S02,S03,A01,A02.  I need to isolate the last R or S or A, which my code does, but then I need to add one to that final variable.  ++ just repeats it.  Is there a simple way to do this then to split up $result ?

 

<?php
$query6 = pg_query("SELECT sublicenses FROM sublicenses WHERE license = '3RF6EWOT2'");
$getarray = pg_fetch_assoc($query6);
$license6 = $getarray['sublicenses'];
echo "$license6 <br><br>";

$string="$license6";
$domain3=strrchr($string,"S");
echo "$domain3<br><br>";
if (!$domain3){echo "no licenses<br><br>";}

$string2=split(",",$domain3);
print_r ($string2);
$result = $string2['0'];
echo "<br><br>$result";

$addstn = $result++;
echo "<br><br>$addstn";
?>

 

So my $result returns what I want, S03.  But my $addstn also returns S03.  I need a final return of S04, in this instance.  Thanks a lot for any tips!

Link to comment
https://forums.phpfreaks.com/topic/159098-solved-adding-1-to-alphanumeric-value/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.