Http://topic.111cn.net/u/20071202/16/e53996de-4725-4dfa-bf14-c197afeed93c.html
? PHP
class Engage
{
Public function GetArray ()
{
$arr 1 = Array (
'' 0 '' => Array ( '' FID '' => 1 , '' Tid '' => 1 , '' name '' => '' Name1 '' ) ,
'' 1 '' => Array ( '' FID '' => 1 , '' Tid '' => 2 , '' name '' => '' Name2 '' ) ,
'' 2 '' => Array ( '' FID '' => 1 , '' Tid '' => 5 , '' name '' => '' Name3 '' ) ,
'' 3 '' => Array ( '' FID '' => 1 , '' Tid '' => 7 , '' name '' => '' Name4 '' ) ,
'' 4 '' => Array ( '' FID '' => 3 , '' Tid '' => 9 , '' name '' => '' Name5 '' )
);
$arr 2 = Array ();
foreach ( $arr 1 as $key => $value )
{
$arr 2 [ $value [ '' FID '' ]][] = Array ( '' Tid '' => $value [ '' Tid '' ] , '' name '' => $value [ '' name '' ]);
}
return $arr 2 ;
}
// Print_r ($arr 2);
$eString = ' Open_door ';
Public function getString ( $eString = NULL )
{
$eString = Explode ( '' _ '' , $eString );
$eString = Array_map ( " Ucfirst " , $eString );
$eString = implode ( $eString , '''' );
return $eString ;
}
/* *
* Bubble Sort
* @return Unknown
*/
Public function getbubble ()
{
$isOver = false ;
$bubbleArray = Array ( Ten , 2 , - , - , Ten , - , A , the , the , the );
$bubbleResult = $bubbleArray ;
Todo {
$bubbleArray = $bubbleResult ;
$isOver = true ;
foreach ( $bubbleArray as $key => $value )
{
if ( $value < $bubbleResult [ $key - 1 ])
{
$bubbleResult [ $key ] = $bubbleResult [ $key - 1 ];
$bubbleResult [ $key - 1 ] = $value ;
$isOver = false ;
}
}
} while ( ! $isOver );
return $bubbleResult ;
}
}
$engage = New engage ();
Print_r ( $engage -> GetArray ());
Echo $engage -> getString ( '' make_by_id '' );
Print_r ( $engage -> getbubble ());
?>
</ Pre >
? PHP
/* *
* The second question is to replace the implementation.
*
*/
function getString ( $eString = NULL )
{
$eString = Preg_replace ( Array ( " /(^[a-z]{1}|_[a-z]{1})/e " , '' /_/ '' ) ,
Array ( " strtoupper (' 1 ') " , '''' ) ,
$eString );
return $eString ;
}
?>