I am writing a script that will grab domain names from a webpage and print a list of ones that match certain criteria.
I have the data in an array but I can't seem to print it out in a friendly format although no matter what I try I cannot seem to extract what I need.
An example of my array is shown below:
Array
(
[0] => Array
(
[0] => domain1.com.au
[1] => domain2.com.au
[2] => domain3.com.au
[3] => domain4.com.au
[4] => domain5.com.au
)
)
Basically I just want to print each occurrence of *.com.au on a new line.
If someone to give me an example or suggestion it would be great.
-
also, please sanitize as Mihai sayd, before storing valuesIonut Flavius Pogacian– Ionut Flavius Pogacian2012年08月20日 11:26:24 +00:00Commented Aug 20, 2012 at 11:26
3 Answers 3
foreach ($array[0] as $domain){
if(strstr($domain, '.com.au')){
echo $domain."<br />";
}
}
1 Comment
The array you supplied should be in $array.
PHP_EOL inserts a newline if you look at the source. <br /> inserts a new line visually
foreach ($array[0] as $domain){
echo $domain.'<br />'.PHP_EOL;
}
Comments
Try:
foreach( $arr[0] as $key => $value)
{
echo '<br/>'. $value;
}