FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » First question and introducing myself
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: First question and introducing myself [message #178031 is a reply to message #178012] Thu, 10 May 2012 22:05 Go to previous messageGo to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma:
Senior Member
On Thu, 10 May 2012 17:18:27 +0200, Shake wrote:

> [stuff about multi dimensional arrays]

I'm not sure if this will work, or if it does, if the result will be what
you want. Feel free to test it out. $a is $_POST and $b is $_SESSION:

<?php

$a = array ( "one" => "a", "two"=>"b", "three"=>"c", "four"=>array
( "une"=>"12","deux"=>"15","trois"=>array
("eins"=>"fred","zwei"=>"jim","drei"=>"3","vier"=>" susan
"),"quatre"=>" james", "cinq"=>"234 ",
"six"=>"mouse"),"five"=>"several words in here" );

$b = array();

function some_validation_function( $var ) {
$var = trim( $var );
return $var;
}

function multi_array_walk( $arr, &$parent ) {
foreach ( $arr as $key => $value ) {
if ( is_array ( $value ) )
multi_array_walk( $value, $parent[$key] );
else if ( is_string( $value ) )
$parent[$key] = some_validation_function( $value );
}
}

var_dump( $a );
var_dump( $b );

multi_array_walk ( $a, $b["post"] );

var_dump( $a );
var_dump( $b );

?>

Rgds

Denis McMahon
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Windows binaries 64bit for PHP
Next Topic: Stats comp.lang.php (last 7 days)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 00:20:36 GMT 2024

Total time taken to generate the page: 0.04898 seconds