3v4l.org

run code in 300+ PHP versions simultaneously
<?php const CODE_MAP = [ 'Reading Comprehension' => 2, 'Elementary Algebra' => 6, 'College Level Math' => 7, 'Sentence Skills' => 1, 'Arithmetic' => 5, ]; const POST_TEST = 'Post Test'; const BASIC_PREFIX = 'AC'; const POST_PREFIX = 'PA'; $BRANCHING_PROFILE = "09. Reading Comprehension - Post Test"; $code = null; foreach (CODE_MAP as $search => $subCode) { if (stripos($BRANCHING_PROFILE, $search) === false) { continue; } $prefix = stripos($BRANCHING_PROFILE, POST_TEST) === false ? BASIC_PREFIX : POST_PREFIX; $code = $prefix . $subCode; break; } var_dump($code);

preferences:
23.82 ms | 405 KiB | 5 Q