0

Hello Every one, I have an issue that is, I want to add an integer into a string for example I have two text field one is called series start and the other one is called series end now if user enters

FAHD1000001 into series start field

AND

FAHD1000100 into series end field

the algorithm should store 100 values into the database with increment into the each entry that is going to store into the database. i.e

FAHD1000001, FAHD1000002, FAHD1000003, ........., FAHD1000100

Is it possible to do so, if yes then how. Please help me

1 Answer 1

1

You have to do something like this but there is a loop hole if you have any numeric value in name like F1AHD00001 than it will not work

$str1 = $request['start'];
$str2 = $request['end'];
$startint=preg_replace("/[^0-9]/","",$str1);
$endint=preg_replace("/[^0-9]/","",$str2 );
$words = preg_replace('/[[:digit:]]/', '', $str1);
for($i=$startint;$i<$endint;$i++){
    $newstring=$words.$i;
    //Save this new String
}
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much you have almost solved my problem now i will make my own regex which will handle that loop hole
Extremely sorry bro completely forgot to accept the answer due to the excitement

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.