php-windows Digest 4 Apr 2012 14:03:14 -0000 Issue 4020

Topics (messages 30822 through 30824):

Class assistance
        30822 by: Gavin

bzChess site (sort of) functional now
        30823 by: Jacob Kruger

Re: Class help
        30824 by: Niel Archer

Administrivia:

To subscribe to the digest, e-mail:
        php-windows-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-windows-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-wind...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Evening all,

I am starting to learn OOP and I am creating a class that validates an array of data to save me escaping and validating:

public function validateArray($testArray)
    {
        $cxn->connection()

        foreach($testArray as $sub)
        {
            // 1
            echo $sub . '<br/><br/>';
        }
    }

At // 1 i am going to escape and validate data, but then want to rebuild the array to pass back.

I cannot work the rebuild of array, can you assist?
--
--

Best Regards,

Gavin Chalkley





--- End Message ---
--- Begin Message ---
For those who don't know about it, have been working on a sort of online 
interactive person-to-person chess game handling engine:
http://www.blindza.co.za/bzChess/

The google code project page for bzChess:
http://code.google.com/p/bz-chess/

Or a direct download URL for the zip file with all source, SQL script file, 
etc. in it - if interested:
http://dl.dropbox.com/u/13327195/bzChess3.zip

Effectively, this is meant to just provide/be a way for various people to play 
chess against other guys, with email notifications relating to opponents moves, 
game states, etc., and, I primarily used it as a form of practice-makes-perfect 
for playing around with specific forms/approaches to web 
development/programming, but anyway...

If you feel like it, have a look, and let me know what you think - there's a 
comment/feedback form once logged in as well, etc., and, yes, there might still 
be bugs/issues with site, since not easiest thing for a developer to test their 
own code/sites, but anyway...<smile>

 Another test/play around page is the one that just lets you mess around with 
moving pieces on board - will still try to validate pieces moves somewhat, but 
since it stores board state per session, once you close browser, it will have 
lost layout as such:
http://www.blindza.co.za/testBoard.php

Lastly, if you think it works ok/well enough, you're also welcome to pass this 
on to other people to have a look at/play around with, and I do still plan to 
make some changes/additions to interface etc., but let's see...

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA

'...fate had broken his body, but not his spirit...'

--- End Message ---
--- Begin Message ---
> Evening all,
> 
> I am starting to learn OOP and I am creating a class that validates an 
> array of data to save me escaping and validating:
> 
> public function validateArray($testArray)
>      {
>          $cxn->connection()
> 
>          foreach($testArray as $sub)
>          {
>              // 1
>              echo $sub . '<br/><br/>';
>          }
>      }
> 
> At // 1 i am going to escape and validate data, but then want to rebuild 
> the array to pass back.
> 
> I cannot work the rebuild of array, can you assist?

Depending on your array, if it is numerically indexed you might be
better off working directly on its elements instead of indirectly with
foreach.

public function validateArray($testArray)
{
    $count = count($testArray);
     for($i=0; $i < $count; ++$i)
     {
          // 1
          echo $testArray[i] . '<br/><br/>';
     }
    return $testArray
}

If you want to work directly on the original array (not a copy passed
into the function), then use a reference in the function signature and
drop the return statement.

public function validateArray(&$testArray)

http://www.php.net/manual/en/language.references.whatdo.php
--
Niel Archer


--- End Message ---

Reply via email to