# Alphanumeric

Please how do I generate a combination of Alphanumeric(2 digits) or both Aphabets(like AA, AB, ZA) in ascending order

as shown below using yii2. Then, it can be saved in database.

A1

.

A9

B1

.

.

.

B9

.

.

.

AB

ZZ

Secondly, how do I get bootstrap for form wizard

Same way as you do in regular PHP:

``````

\$alphabet = range(0, 9) + range('A', 'Z');

\$result = [];

foreach (\$alphabet as \$letter1) {

foreach (\$alphabet as \$letter2) {

\$result[] = \$letter1 . \$letter2;

}

}

var_dump(\$result);

``````

Haven’t got second question. Could you elaborate?

Thanks a lot. Am very grateful. You solved my problem.

However I have this little challenge, I dont want the two digits to be numeric.

It should be either Alphanumeric or alphabets, as show below.

A1

.

A9

B1

.

.

.

B9

.

.

.

AB

ZZ

The code you gave me generates this:

Numeric: 00, 01, …

Aphanumeric: A0, A1, …

Aphabets: AA, AB…

The Second question is, I want to do Form wizard in Yii2.

I have these models

PatientInfo

Controller

``````

public function actionCreate()

{

\$model = new PatientInfo();

return \$this->redirect(['view', 'id' => \$model->patient_id]);

} else {

return \$this->render('create', [

'model' => \$model,

]);

}

}

``````

Model

``````

public function attributeLabels()

{

return [

'patient_id' => 'Patient ID',

'email' => 'Email',

'mobile_line' => 'Mobile Line',

'other_lines' => 'Other Lines',

'first_name' => 'First Name',

'middle_name' => 'Middle Name',

'last_name' => 'Last Name',

];

}

``````

PatientDependant

Model

``````

public function attributeLabels()

{

return [

'dependant_id' => 'Dependant ID',

'patient_id' => 'Patient ID',

'first_name' => 'First Name',

'middle_name' => 'Middle Name',

'last_name' => 'Last Name',

];

}

``````

PatientMedicalInfo

Model

``````

public function attributeLabels()

{

return [

'patient_medical_id' => 'Patient Medical ID',

'patient_id' => 'Patient ID',

'pref_med_cond' => 'Pref Med Cond',

'allergies' => 'Allergies',

'prior_surgery' => 'Prior Surgery',

'medications' => 'Medications',

];

}

``````
1. It will first load the info on PatientInfo, When I click on Next, it saves and move to PatientDependant

2. On patientDependant, When I click on Next, it saves and move to PatientMedicalInfo. But when I click Previous, it moves back to PatientInfo.

3. On patientMedicalInfo, When I click on Finish, it saves and display everything on a view. But when I click Previous, it moves back to PatientDependant.

Thanks

As for the generation, you got the idea. Adjusting this could should not be a huge problem.

For multi-step forms there are extension available:

<?php

\$alphabet = range(‘A’, ‘Z’) + range(0, 9);

\$result = [];

foreach (\$alphabet as \$letter1) {

``````foreach (&#036;alphabet as &#036;letter2) {

&#036;result[] = &#036;letter1 . &#036;letter2;

}
``````

}

var_dump(\$result);

?>

When I used this, its showing me the combination of alphabets alone. I need something like

A1…A9

. .

. .

Z1 Z9

. .

. .

AA AZ

. .

. .

ZA ZZ

<?php

\$alphabet = range(‘A’, ‘Z’) + range(0, 9);

\$result = [];

foreach (\$alphabet as \$letter1) {

``````foreach (&#036;alphabet as &#036;letter2) {

&#036;result[] = &#036;letter1 . &#036;letter2;

}
``````

}

var_dump(\$result);

?>

When I used this, its showing me the combination of alphabets alone. I need something like

A1…A9

. .

. .

Z1…Z9

. .

. .

AA…AZ

. .

. .

ZA…ZZ