You are here: Re: Really hardcore question about PHP needed :) « PHP Programming Language « IT news, forums, messages
Re: Really hardcore question about PHP needed :)

Posted by Steve on 04/16/07 19:54

"andre rodier" <andrerodier@free.fr> wrote in message
news:4623cc1c$0$6299$426a74cc@news.free.fr...
| Problem 1:
| We want to parse each element of an array contained in an object, but
| without leaving the scope of the object, and without use global vars.
| Our code contain an error, and you have to find the error, and the
solution.
| Sample code here :

array_walk, afaicr, is not aware of object instances and therefore would not
be able to find 'searchInLines'...causing your error.

a solution is to simply use array_search...which never leaves php native
code - array_walk does.

another good question to ask is, why do people not standardize their
nomanclature? why pascal 'Search' yet camel everything else including the
name of the class itself?


| class object
| {
| var $lines ;
| var $posFound ;
|
| function object()
| {
| $lines = array( ... ) ;
| ...
| }
|
| function Search($val)
| {
| /* Line with error : */
| array_walk($this->lines, 'searchInLines', $val );
|
| /* solution : */
| array_walk($this->lines, array( $this,'searchInLines'), $val );
| }
|
| function searchInLines(&line, $id, $valueToSearch)
| {
| if ( $line[$id] == $valueToSearch )
| $this->posFound = $id ;
| }
| }
|
|
| --
| tasteless wrote:
| > Hi guys,
| >
| > I need really hard questions (about 10) about PHP programming (some of
| > elements OOP as well, but no MySQL questions - this is different part),
| > this questions needs to be very hard, but the experienced senior PHP
| > developer should answered on it.
| >
| > I've already searched in google and google groups archive but without
| > any good results. So could anybody help me giving some link or sending
| > some stuff to me ?
| >

 

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

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