DavidWare
asked on
$_SESSION[cart][$product_name] returns { Array[Bowl_in_Green_glaze] }
$_SESSION[cart][$product_n ame] returns { Array[Bowl_in_Green_glaze] }
Is there a Mid$ function and a Left$ function in PHP so I can trim off the first 8 and the last 3 characters?
(or is there a way to filter that intrinsically?)
Oh, and for the extra 9 points, why is this failing as "Fatal error: Unsupported operand types" ?
$total += ( $_SESSION['cart'][$product _name]['pr ice'] * $count );
it also fails like this:
$total = $total + ( $_SESSION['cart'][$product _name]['pr ice'] * $count );
Thanks,
David
Is there a Mid$ function and a Left$ function in PHP so I can trim off the first 8 and the last 3 characters?
(or is there a way to filter that intrinsically?)
Oh, and for the extra 9 points, why is this failing as "Fatal error: Unsupported operand types" ?
$total += ( $_SESSION['cart'][$product
it also fails like this:
$total = $total + ( $_SESSION['cart'][$product
Thanks,
David
ASKER
Hello guston76,
Thanks for the help.
This returns an error
Notice: Array to string conversion in /var/www/sites/mysite.com/ cart.php on line 125
Thanks,
David
Thanks for the help.
This returns an error
Notice: Array to string conversion in /var/www/sites/mysite.com/
Thanks,
David
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Is there a Mid$ function in PHP?
This is an important part of the question.
I'm adding a few points for this clarification.
Thanks!
This is an important part of the question.
I'm adding a few points for this clarification.
Thanks!
ASKER
Oh, substr()
Thanks for your help!
Thanks for your help!
ASKER
Oh, substr()
Thanks!
Thanks!
function left($string, $length) {
return substr($string, 0, $length);
}
// RIGHT FUNCTION
function right($string, $length) {
return substr($string, strlen($string)-$length);
}
// FUNCTION TO CUT STRING FROM LEFT AND RIGHT
function cut_string($string, $chars_from_left, $chars_from_right) {
return substr($string, $chars_from_left, strlen($string)-$chars_fro
}
// FOR YOUR SITUATION...
$s = cut_string ( $_SESSION[cart][$product_n