You are here: Re: array help « All PHP « IT news, forums, messages
Re: array help

Posted by J.O. Aho on 12/03/07 19:27

Darrell wrote:

> <?php
> error_reporting(E_ALL);
> $Buf = file("bsshort2.txt");
> print_r ($Buf);
> $aKeys = array_keys($Buf,("chuck"));
> print_r ($aKeys);
> ?>
>
> prints out the file with all of the keys and then prints Array ( )
> Array ( [11] => 11)
>
> What I really want to search for is <HR> but originally thought I was
> having trouble searching for <HR> so I tried "chuck".

The search in the array_keys if for searching in the keys and not the content
in the cells (there are plenty other functions for that).

The parentheses around chuck don't give you any advantage, drop those and get
a code that is easier to understand. Don't forget to use indentation and you
make the code even easier to read.

Not sure, but the following code may be more of use for you...

$Buf = file("bsshort2.txt");
foreach($Buf AS $key => $value) {
echo $key." => ".$value."\n";
if(!(stristr($value, '<HR>') === FALSE)) {
echo "there was a horizontal line on the {$key} line\n";
}
}

--

//Aho

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация