Page 1 of 1
Adding somthing before words
Posted: Tue Nov 07, 2006 12:53 am
by nickman013
Hello, I have over 1000 proxy IP's in an array, I want to add the word "deny from" before each ip, and echo it out so I have the full list of ips with deny from before it.
For example
323.232.12.32:3233
239.21.24.5:8080
67.3.25.66:90
i want to replace to
deny from 323.232.12.32:3233
deny from 239.21.24.5:8080
deny from 67.3.25.66:90
Is it possible to do this??
Thanks!!!
Posted: Tue Nov 07, 2006 1:53 am
by timvw
Use
foreach to iterate over the elements, and
echo a concatenation of "deny from" and the array element.
Posted: Tue Nov 07, 2006 2:18 am
by jimthunderbird
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Code: Select all
<?php
$proxy_ips = array(
'323.232.12.32:3233',
'239.21.24.5:8080',
'67.3.25.66:90'
);
for($k=0;$k<count($proxy_ips);$k++){
$proxy_ips[$k] = "deny from ".$proxy_ips[$k];
}
foreach($proxy_ips as $ip){
print $ip."<br/>";
}
?>
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Tue Nov 07, 2006 10:36 am
by nickman013
thanks alot.
it made my life a zillion times easier