PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
lets say for example, in a php file i had this written in it:
==Start Example==
1
2
3
4
5
6
7
8
9
10
==End Example==
what i want to do, is i only want to remove ONE number that i select, so when i type http://www.site.com/numbers?delete=8, it would delete the number 8. how would i do this?
ONLY SPECIFIED TEXT IS WHAT I WANT TO DELETE, NOT THAT WHOLE THING!
// if it has a line feed after it you may want to uncomment this line
//$NumberToDelete = $NumberToDelete . "\n";
$NewFile = str_replace($NumberToDelete, null, $OldFile);
That will delete all the 1's in the file for example. You may want to ensure that all the data in the file is prepended and appended by a space or some other character.
wait, i put the thing in there, but im kinda confused cuz i dont think its in the right order. and i also dont know what parts of the code i should take out. can anyone help? this code is for trying to take out the IPs. cuz i have 2 files, ban.php and deleteip.php. ban.php is where all the ips are stored and deleteip.php is where i will be able to delete them.
here is an example of what ban.php looks like:
127.0.0.1
127.0.0.2
127.0.0.3
127.0.0.4
68.0.5.6
and i want deleteip.php?delete=127.0.0.3 to delete the ip "127.0.0.3" maybe this will help you guys alittle more on what i need?
Looks like feyd spent some time to write some good code for you. You might want to spend some time looking up all the functions in the manual to understand it better.