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

  • SEARCH
  • Home
  • 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 7877041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:16:06+00:00 2026-06-03T03:16:06+00:00

i am trying to learn php as i Study genetics and this would be

  • 0

i am trying to learn php as i Study genetics and this would be useful for bioinformatics. I am having trouble with my code and im sure its something very stupid but i cant see a solution.

this is my code:

    $query="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC";

$seq=chunk_split($query,40,"<br />");

$truecol="<div style=\"color: hsl(0,100%,50%);\">";


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 "</div>";
        }

           echo $nucl;
    }
    echo "\n";
}
colorSequence($seq,5,$truecol,3);

The output gives:

AAAAAAAAAA
(this is coloured)AAAAA(end of colour)
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC

The first row has 10 letters the second has 5 coloured letters and the 3rd row has 45 letters. All rows should have 60 letters. Can anyone help?

  • 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-03T03:16:07+00:00Added an answer on June 3, 2026 at 3:16 am

    You might want to use the <span> HTML tag instead of <div>.

    Because each <div> is normally displayed by browsers with a line-break above and below.

    Alternatively you can define how <div> should look like with CSS, but I think that’s too much for the moment:

    div {display: inline;}
    

    Example with the <span> HTML element and using substr (I might be off by one or so, I assume you can fix that):

    $truecol = 'hsl(0,100%,50%)';
    colorSequence($seq, 5, $truecol, 3);
    
    function colorSequence ($seq, $position, $truecol, $TFBSlength)
    {
        $before = substr($seq, 0, $position);
        $color  = substr($seq, $position, $TFBSlength);
        $after  = substr($seq, $position + $TFBSLength);
        printf("%s<span style=\"color: %s;\">%s</span>%s\n",
               $before, $truecol, $color, $after);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to learn the code igniter library and object oriented PHP in general
I am a PHP web programmer who is trying to learn C#. I would
I'm trying to learn how to use the library vcglib (http://vcg.sourceforge.net/index.php/Main_Page) but I'm having
I'm trying to learn xQuery coming from a php background, I have this expression
I'm trying to learn some PHP, and I've been banging my head against this
I am trying to learn url rewriting. My code: RewriteEngine on RewriteRule ^/$ /index.php
I am trying to learn oop in php, but the below code is not
I am new to PHP and trying to learn some so sorry if this
I am trying to learn PHP classes so I can begin coding more OOP
i'm trying to learn php/mysql. inserting data into mysql works fine but inserting those

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.