I have problem with building a cart. How can I get all the sessions that starts with the same word?
2条回答 默认 最新
- doupuzhimuhan9216 2016-09-24 07:46关注
$start = 'startingword'; $new_session = array(); foreach($_SESSION as $index=>$value) { $temp = explode(' ', $index, 2); if($temp[0] == $start) { $new_session[$index] = $value; } }
If the starting word is session value and not index, then,
foreach($_SESSION as $index=>$value) { $temp = explode(' ', $value, 2); if($temp[0] == $start) { $new_session[$index] = $value; } }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报