How to map numbers utilizing array function
Question
I would have thought this would be simple, however, I’m having a hard time with it. I have this function and I’m having a hard time mapping numbers. I have a spreadsheet that I import with WP All Import and utilize this function for a variety of other fields that are not numbers and it works great. Anybody have any thoughts on what I’m doing wrong? Thank you in advance.
function seating_translate_data_sample( $data ) {
if (empty($data)) {
echo "Not Specified";
}
$map = array(
'2' => '2 Passenger',
'4' => '4 Passenger',
'6' => '6 Passenger',
'8' => '8 Passenger',
'10' => '10 Passenger',
);
foreach ( $map as $partial_match => $mapped_value ) {
if ( stristr( $data, $partial_match ) ) {
return $mapped_value;
}
}
return $data;
}
0
functions
3 years
2020-06-01T15:10:19-05:00
2020-06-01T15:10:19-05:00 0 Answers
86 views
0
Leave an answer