Link to home
Start Free TrialLog in
Avatar of XK8ER
XK8ERFlag for United States of America

asked on

disable if 75 percent of links are not online

hello there,
I have here $totallinks that holds the number of total links and I also have $alivelinks that hold the total of links that are online..
how can I make an if statement showing a warming like.. "found 75 % of dead links"
Avatar of Ionut A. Tudor
Ionut A. Tudor
Flag of Romania image

see below for an example

<?php
$totallinks=120;
$alivelinks = 13;
 
$deadlinks=$totallinks-$alivelinks;
 
$deadlinkspercent = sprintf("%.2f",($deadlinks/$totallinks)*100);
 
echo "found $deadlinkspercent% of dead links"; 
 
?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ionut A. Tudor
Ionut A. Tudor
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
like this

<?php
$totallinks=100;
$alivelinks =20;
$percent = 1-($alivelinks/$totallinks);
if ($percent >= 0.75) {
$percent = sprintf("%.2f",$percent*100);
echo "You have $percent% dead links";
} else {
echo "do nothing";
}
?>

Open in new window