为PHP数组中的各个变量指定颜色

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,
})  

You can generate any random color using the following function and assign to your array as color attribute.

function random_color_part() {
        return str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT);
    }

    function random_color() {
        return random_color_part() . random_color_part() . random_color_part();
    }

if( has_term( $categories[0], 'product_cat', $product_id ) )
    echo json_encode(array(strtoupper($categories[0]) => $counts[0],'color' => random_color())); // Returned value to jQuery
if( has_term( $categories[1], 'product_cat', $product_id ) )
    echo json_encode(array(strtoupper($categories[1]) => $counts[1],'color' => random_color())); // Returned value to jQuery
}

Generating a random hex color code with PHP