Im having an issue with outputting a certain session inside a foreach loop, a session that contains a certain string of characters:
function cart(){
foreach($_SESSION as $name => $value){
}
}
doing so ^
, outputs all the sessions, and i want it to output only the sessions that contain the $name cart_
.
If any of you has an idea on how to do so, it will be much appreciated.
It looks like you could make use of strpos:
function cart() {
foreach($_SESSION as $name => $value) {
if(strpos($name, 'cart_') !== FALSE) {
//echo here
}
}
}