Wait for VPN connection to be established loop

I was looking for a way in PHP to check and wait for vpn connection (tun0 interface) to come up before continuing with the code
here is what I come up with but it's not seeing any change after interface tun0 is up