Page 1 of 1

How to increment a number and keep as a string?

Posted: Tue Feb 21, 2006 10:15 pm
by Deseree
Input =

$setup_username1 = test0001;

Code: Select all

$setup_username_test = explode("test",$setup_username1);
	
	$setup_number = $setup_username_test[1];
	
	$setup_number = strval(intval($setup_number)+1);
It STILL always shows u as test1 and I need it to show up as all four.

How can I do this please? I just spent an hour and a half trying many things gettting nowhere. strval() did not work.

Posted: Tue Feb 21, 2006 10:51 pm
by feyd

Code: Select all

[feyd@home]>php -r "$a = 'test000001'; echo $a 1;"
1
[feyd@home]>php -r "$a = 'test000001'; echo ++$a;"
test000002
Interesting to say the least. :)