I'm not sure if this is possible, but the concept is similar to using strtoupper
. I am trying to set a color # value for each of the items in the array. Is there a valid PHP color function which can be applied here?
e.g. [0] = #ed7b7 [1] = #c13f0
These values are being called later on in the code using jQuery to display in a Javascript SweetAlert and I am trying to get each of the strings to appear as a different colour within the alert.
Segment of code where I am converting string to uppercase:
// Return the product category count that belongs to the added item
if( has_term( $categories[0], 'product_cat', $product_id ) )
echo json_encode(array(strtoupper($categories[0]) => $counts[0])); // Returned value to jQuery
if( has_term( $categories[1], 'product_cat', $product_id ) )
echo json_encode(array(strtoupper($categories[1]) => $counts[1])); // Returned value to jQuery
}
And here is the Javascript alert where I am then trying to call the modified response with the colored variables:
success: function (response) {
$.each( JSON.parse(response), function( category, count ) {
if( count == 4 ){
swal({
type: 'success',
title: "You've Added The 4 Minimum "+category+" Items!",
allowOutsideClick: false,
showCancelButton: false,
showConfirmButton: false,
timer: 3000,
})