Reputation: 8836
In a variable $price
I have those values separated by comma. Each one represent a day.
1st value,2nd value,3rd value,4th value,5th value,6th value,7th value
If I have a $day
variable can I find the value ? What I mean is like
if ($day == "Monday")
echo the 2nd value of $price
.
Upvotes: 2
Views: 94
Reputation: 522145
$pricePerDay = array_combine(array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'),
explode(',', $price));
echo $pricePerDay['Mon'];
Upvotes: 1
Reputation: 8886
Try this
$var="1st value,2nd value,3rd value,4th value,5th value,6th value,7th value";
$var_exploded=explode(",",$var);
if you want second value
echo $var_exploded[1];
Upvotes: 0
Reputation: 724
You can look up the function explode(',',$price);
and use that to help you out. You'll need a loop to get through the values and determine if it is the specific day.
Upvotes: 0