This works for me just fine give it a try (the only real difference is the trim
on status and the verification for empty entries on the array as well as the if/echo for the found/not found):
<?php
$services = <<<DATA
root 833 0.0 0.1 1852 768 ? S 19:25 0:00 daemon -r -n udp-server1 /usr/bin/ncd/udp-server.php wifi:3333:true:true.
root 834 0.0 0.1 1852 768 ? S 19:25 0:00 daemon -r -n udp-server2 /usr/bin/ncd/udp-server.php network:13000:false:false.
root 848 48.6 2.3 37036 11744 ? R 19:25 18:07 /usr/bin/php /usr/bin/ncd/udp-server.php wifi:3333:true:true.
root 849 48.6 2.3 37064 11780 ? R 19:25 18:07 /usr/bin/php /usr/bin/ncd/udp-server.php network:13000:false:false.
www-data 1675 0.0 0.0 1368 444 ? S 20:02 0:00 sh -c ps aux | grep udp
www-data 1677 0.0 0.1 1456 528 ? S 20:02 0:00 grep udp
DATA;
$statuses = <<<DATA
wifi:3333:true:true
network:13000:false:false
DATA;
$status = explode("\n",$statuses);
print_r($status);
foreach($status as $current_status)
{
$new_status = trim($current_status);
if (empty($new_status))
continue;
if (strpos($services,$new_status)!==false)
{
echo $new_status, " was found...\n";
}
else
{
echo $new_status, " was not found...\n";
}
}
And with your code it should look like:
<?php
$services = shell_exec('ps aux | grep udp');
$statuses = explode("\n",file_get_contents('/var/www/misc/udp-settings.inc'));
$status = explode("\n",$statuses);
foreach($status as $current_status)
{
$new_status = trim($current_status);
if (empty($new_status))
continue;
if (strpos($services,$new_status)!==false)
{
echo $new_status, " was found...\n";
}
else
{
echo $new_status, " was not found...\n";
}
}