reklanummer - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of reklanummer.php
- <?php
- $Reklamationsnummer=array('L_2023434_334','2021_0124','2021_10000','2021_9999');
- $year = '2021';
- foreach($Reklamationsnummer as $val){
- if(ord($val) == 50){
- $reklanum[] = $val;
- }
- }
- if(empty($reklanum) === true){
- $counter = '0001';
- $neuReklanum = $year.'_'.$counter;
- echo('neue Rekla ist: '.$neuReklanum."\n");
- }else{
- //In $maxReklanum wird die maximale Reklamationsnummer, die mit '2' beginnt gespeichert
- if(!empty($reklanum)) $maxReklanum = max($reklanum);
- //Anschließend wird aus der Nummer der Anhang ohne Jahr extrahiert und
- $ergebnis = substr($maxReklanum, 5);
- $ergebnis++;
- $ergebnisTrimm = ltrim($ergebnis,'0');
- $length = 4;
- /*Überprüft das Jahr der Reklamationsnummer. Wenn das aktuelle Jahr gleich dem
- der Reklamationsnummer ist, wird eine neue Nummer durch Hochzählen erzeugt
- und in das Prozessfeld 'Reklamationsnummer' übergeben. Andernfalls wird wieder
- neu von '0001' begonnen*/
- if($year == substr($maxReklanum,0,-5)){
- $ergebnisTrimm = str_pad($ergebnisTrimm ,$length,'0000', STR_PAD_LEFT);
- $maxReklanum = $year.'_'.$ergebnisTrimm;
- echo('Neue Nummer ist (Jahr gleich): '.$maxReklanum."\n");
- }else{
- $ergebnisTrimm = '0001';
- $maxReklanum = $year.'_'.$ergebnisTrimm;
- echo('Neue Nummer ist: '.$maxReklanum."\n");
- }
- }
File Description
- reklanummer
- PHP Code
- 21 Jun-2021
- 1.7 Kb
You can Share it:
Latest PHP Pastes