$err is only visible in the scope of your displayErr() function. You need to pass it, or its values, around. A couple of options:
Return the error message and append to $err within the calling scope
function displayErr() {
return "You have an error";
}
$err = array();
if($bla==false) { $err[] = displayErr(); }
if(!empty($err)) { print_r($err); }
Use global
function displayErr() {
global $err;
$err[] = "You have an error";
}
$err = array();
if($bla==false) { displayErr(); }
if(!empty($err)) { print_r($err); }
Also, print_r() outputs stuff by itself, you don't need to echo print_r().
displayErris not displaying the errors at all.