<?php

/* Testdata 
$bibliographicArray = [
[ 'fieldId' => 'titleinput1', 'fieldValue' => 'Titel',  'fieldType' => 'textarea', 'inputType' => 'text', 'isSelected' => 1 ] ,
[ 'fieldId' => 'authorinput1', 'fieldValue' => 'Keck, Roland', 'fieldType' => 'input', 'inputType' => 'text', 'isSelected' => 1 ] ,
[ 'fieldId' => 'authorinput2', 'fieldValue' => 'Keck, Sabine', 'fieldType' => 'input', 'inputType' => 'text', 'isSelected' => 1 ] ,
[ 'fieldId' => 'publicationyearinput1', 'fieldValue' => '2020',  'fieldType' => 'input', 'inputType' => 'text', 'isSelected' => 1 ] ,
[ 'fieldId' => 'abstractinput1', 'fieldValue' => 'Abstract', 'fieldType' => 'textarea', 'inputType' => 'text', 'isSelected' => 1 ] 
]; 
*/

$resArrayBibliographic = []; 
foreach ($bibliographicArray as $content)  {
	switch ($content['fieldId'])  {
	    case 'titleinput1': 	$resArrayBibliographic['Titel'] = $content['fieldValue']; 
					break; 
	    case 'authorinput1':  
	    case 'authorinput2': 
	    case 'authorinput3': 
	    case 'authorinput4': 
	    case 'authorinput5': 
	    case 'authorinput6': 
	    case 'authorinput7': 
	    case 'authorinput8': 
	    case 'authorinput9':    	if (strlen($content['fieldValue'])) {
		    				$resArrayBibliographic['Verfasser'][] = $content['fieldValue'];
				    	}
		    			break; 
	    case 'publicationyearinput1': 
		    			$resArrayBibliographic['Erscheinungsjahr'] = $content['fieldValue'];
                                	break;
	    case 'abstractinput1':	
	    case 'abstractinput2':
	    case 'abstractinput3': 	if (strlen($content['fieldValue'])) {
		    				$resArrayBibliographic['Abstract'][] = $content['fieldValue'];
					}
                                  	break;
	}
}

//print_r ($resArrayBibliographic); 
// $resArrayBibliographic = json_encode($resArrayBibliographic);
//print_r ($resArrayBibliographic);

?>
