Overwrite values
-
For many days I have been racking my brains over how to solve one problem, but nothing happens =)
Can you tell me the code I need to use?
There are goods that are divided into 3 values: “Adults”, “Children”, “Babies”.
In turn, these products have gender, but the file is not specified correctly, like this:<param name=”Age”> – “Adults”, “Children”, “Babies”
<param name=”gender”> – “male”, “female”, “None”“Adults” – “male”, “female”
“Children” – “male”
“Babies” – “None”How to write code like this so that:
If the product is “Adults”, then write down what is indicated in the file, if the product is “children” or the product “Babies”, then write down this value – “For girls | For boys”I understand that I am not going too far when I ask you to help me, nevertheless I really hope that you can tell =)
My code is half working. Products for children still have the meaning “for male”:
[my_map_data({param[@name="gender"]})]
///////////* Gender Attribute*/ function my_map_data( $data ) { $map = array( 'male' => 'for male', 'female' => 'for female', 'None' => 'for girls|for boys', ); return ( array_key_exists( $data, $map ) ) ? $map[ $data ] : $data; }
- The topic ‘Overwrite values’ is closed to new replies.