Reply to Re: how best to avoid brute-force looping?

Your name:

Reply:


Posted by Captain Dondo on 04/14/06 20:35

Captain Dondo wrote:
> First of all, thanks for the serialize pointer in an earlier thread.
> That looks like it's the ticket.
>
> Now, I have a style/php question. (I am a C hacker by background, and
> thus everything is a loop... But PHP is different...)
>
> OK, I write out my array and read it back in. It comes in thus:
>
> Array (
> [currentField] => 103
> [brgf1] => 0.000000
> [brgt1] => 1.000000
> [axa1] => 1
> [brgf2] => 2.000000
> [brgt2] => 2.000000
> [axa2] => 2
> [axb2] => 2
> [axc2] => 2
> [axd2] => 2
> [brgf3] => 2.000000
> [brgt3] => 3.000000
> [axa3] => 2
> [axb3] => 2
> [axc3] => 2
> [axd3] => 2
>
> ....
> ....
> )
>
> Basically each line consists of two bearings and 4 true/false switches.
> The line number in the schedule is apended to the name of the field.

OOPS! Looks like I left out a line....

I need to output this to a webpage, using input fields like this:

<tr>
<td>%d</td>
<td><input name='brgf%d' type=text value='%f' maxLength="5" size="5"></td>
<td><input name='brgt%d' type=text value='%f' maxLength="5" size="5"></td>
<td><input name='axa1' type='hidden' value='%d' size='3'
readonly='readonly'>
</tr>

>
> In my C mind, this calls for a loop, bruteforcing our way and appending
> the counter to each name....
>
> But I *know* there is a more elegant PHP way to do this. While it makes
> sense in C, it just looks fugly in PHP....
>
> As I use PHP to generate the field names, I can change those if it makes
> things easier....
>
> Thanks,
>
> --Yan

[Back to original 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

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