You need to pass $myFormat
as a parameter. Also, the parameters to sprintf
must match the function parameters.
function dataHandling($format, $a1,$a2...){
// Sorting and storing relevant data
echo sprintf($format,$a1,$a2...);
}
try {
dataHandling($myFormat, $s1,$s2...);
}
catch{
// Error handling if there's a db issue
}