Page 2 of 2
Posted: Mon Jul 01, 2002 2:46 am
by Lance705
So like "C:\Epsilon\Epsilon.exe *"?
Posted: Mon Jul 01, 2002 2:51 am
by Lance705
Warning: Invalid argument supplied for foreach() in c:\apache\htdocs\uomindblast\servercontrols\kill.php on line 2
Posted: Mon Jul 01, 2002 2:54 am
by hob_goblin
well * only subsitutes for one character.. so.. like i said, im not the person to ask on this... i never understood all of php's wildcards
Posted: Mon Jul 01, 2002 2:55 am
by Lance705
YES! GO MAC U RULE THX!
Posted: Mon Jul 01, 2002 2:58 am
by twigletmac
When you did foreach does your code look like this:
Code: Select all
$proccessname = "Epsilon";
exec("C:/kill/PS", $poslist) or die('failed executing PS');
foreach ($poslist as $id => $value) {
if (preg_match('/epsilon/i', $value)) {
echo $id;
}
}
since using your posted output from $poslist and the foreach loop above I got the expected answer, 30.
Mac
Posted: Mon Jul 01, 2002 3:01 am
by Lance705
I got it. thx.
Posted: Mon Jul 01, 2002 3:04 am
by Lance705
whoa, wait. What is 30. Is it the array table with epsilon in it? It is showing the table that contains ps...
Posted: Mon Jul 01, 2002 3:11 am
by twigletmac
Nope it's the key that you're looking for so to get the value associated with that key you could have:
Code: Select all
$proccessname = "Epsilon";
exec("C:/kill/PS", $poslist) or die('failed executing PS');
foreach ($poslist as $id => $value) {
if (preg_match('/epsilon/i', $value)) {
echo $value;
}
}
Mac
Posted: Mon Jul 01, 2002 3:12 am
by Lance705
now it is returning the wrong one
Code: Select all
<?
exec("C:/kill/PS", $poslist)
or die('failed executing PS');
foreach ($poslist as $id => $value) {
if (preg_match('/epsilon/i', $value)) {
echo $id;
}
}
print("\n$poslistї$id]\n");
print("$poslistї$value]\n");
?>
Output:
30 C:\kill\ps.exe 0x94c
Posted: Mon Jul 01, 2002 3:13 am
by Lance705
It is still returning 30, although my proccess list has changed andd Epsilon no longer resides on 30.
Posted: Mon Jul 01, 2002 3:17 am
by twigletmac
It's not getting the wrong one it's just remembering the last value of $id which is the last key in the array because of the foreach loop...
This is what you were trying to do (but will return the correct value corresponding to the key found):
Code: Select all
<?php
exec("C:/kill/PS", $poslist) or die('failed executing PS');
foreach ($poslist as $id => $value) {
if (preg_match('/epsilon/i', $value)) {
$search_key = $id;
}
}
echo $search_key.' '.$postlistї$search_key];
?>
Mac
Posted: Mon Jul 01, 2002 3:19 am
by twigletmac
It is still returning 30, although my proccess list has changed and Epsilon no longer resides on 30.
Have you checked this using print_r() on the output from PS again?
Mac
Posted: Mon Jul 01, 2002 3:21 am
by Lance705
Ok, I get it now. Thank you for you time =)