Posted by Tom
2014-06-03
You can use this function to get the corresponding value of a particular key.
This is code to test the function.
define( 'SEL_AD_COLOR', "
S1001=Blue
S1002=Green
S1003=Yellow
" );
function getColorVal( $key ) {
if ( preg_match( '/\n'.$key.'=(.+)\r?\n/', SEL_AD_COLOR, $mx ) ) {
return $mx[1];
} else {
return '';
}
}
This is code to test the function.
echo getColorVal( 'S1002' ); // displays 'Green'
instead:
When echo $rs['ad_type'] ,I get: S1001
should be:
When echo $rs['color'] ,I get: S1001
sorry...