Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7896507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:54:44+00:00 2026-06-03T07:54:44+00:00

I have this code done, however it is not working the way I would

  • 0

I have this code done, however it is not working the way I would like. I am trying to color a piece of a string. The color is decided by a function getcolor, which is decided by a function called raw transform, which will transforma raw score into a score from 1-9 for my switch case. Can anyone offer some help? $col is assigned by another function- for arguments sake lets say it is defined as: $col= 0.

<?php

$raw= 650;
function rawtransform($raw) {
  $score = (int)($raw/50)-9;
}
    //==========================================================================
//            Function to decide which color system                         //
//==========================================================================   
function getcolor($score, $col)
{
switch ($score){
// to return the function best way is to declare the case outcome as a variable eg.$truecol
case 1: /*500-550(Raw Score)*/
    $truecol="<span style=\"color: hsl($col,100%,90%);\">";
    break;
case 2: //550-600
    $truecol="<span style=\"color: hsl($col,100%,80%);\">";
    break;
case 3: //600-650
    $truecol="<span style=\"color: hsl($col,100%,70%);\">";
    break;
case 4: //650-700
    $truecol="<span style=\"color: hsl($col,100%,60%);\">";
    break;
case 5: //700-750
    $truecol="<span style=\"color: hsl($col,100%,50%);\">";
    break;
case 6: //750-800
    $truecol="<span style=\"color: hsl($col,100%,40%);\">";
    break;
case 6: //800-850
    $truecol="<span style=\"color: hsl($col,100%,30%);\">";
    break;
case 7: //850-900;
    break;
case 8: //900-950
    $truecol="<span style=\"color: hsl($col,100%,20%);\">";
    break;
case 9: //950-1000
    $truecol="<span style=\"color: hsl($col,100%,10%);\">";
    break;
   }
}

   $query="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC";

$seq=chunk_split($query,50,"<br />");
getcolor($score);
function colorSequence ($seq,$position,$truecol,$TFBSlength){
    $nucleotides = str_split($seq);
    foreach ($nucleotides as $index => $nucl){
        if ($index == $position){
            echo $truecol;
        }
        if ($index == $position + $TFBSlength){
            echo "</span>";
        }

        echo $nucl;
    }
    echo "\n";
}
colorSequence($seq,49,$truecol,1);
?>

The output does not include the coloring of the selcted nucleotides. Anyone know why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:54:45+00:00Added an answer on June 3, 2026 at 7:54 am

    You do not assign the return value of getcolor($score); to a variable. I bet it should be like $truecol = getcolor($score); before calling colorSequence($seq,49,$truecol,1);.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Quick question, What have I done wrong here. The purpose of this code is
i have done some code in jquery but where i commented in this bellow
I have found myself doing this in my code to 'cache' the work done
I'm not a Notes programmer, however, for my sins, have been working on some
I have this code working when I build for debug on my phone and
I have this code that throws a math domain error exception: v = -1.0
I have this code, the idea is to read from a file and the
i have this code preg_match_all('%(?:youtube\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^&?/ ]{11})%i', $asd, $match); to find youtube key of urls
i have this code: <!DOCTYPE HTML> <html> <head> <script src=http://ajax.googleapis.com/ajax/libs/dojo/1.7.1/dojo/dojo.js type=text/javascript djConfig=parseOnLoad: true></script> <script
I have this code to get the local date/time. It works but it seems

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.