Hi,
I have a website full of code snippets at http://syntax.cwarn23.info/PHP:_Contents but I need some ideas of small scripts that I can make for the example list. So there are some examples of what I have done at that link but I don't want the examples to be too complex.

Any ideas of simple php examples I can make?

Recommended Answers

All 4 Replies

Well, looking through a few of them they could use some improvement, most notably the hex to rgb function, hexdec is your friend.

function torgb($string)
{
  $string = str_replace("#","",$string);
  $r = substr($string, 0, 2);
  $g = substr($string, 2, 2);
  $b = substr($string, 4, 2);
  return array(hexdec($r), hexdec($g), hexdec($b));
}

I just love finding new functions that I never new existed! Is it ok if I include the following code in there saying with the help of ShawnCplus?

function hex_to_rgb($color,$rgb) {
    $color=str_replace("#",'',$color);
    $color_red = substr($color, 0, 2);
    $color_green = substr($color, 2, 2);
    $color_blue = substr($color, 4, 2);
    if ($rgb='r' || $rgb='red') {
        return hexdec($color_red);
        }
    if ($rgb='g' || $rgb='green') {
        return hexdec($color_green);
        }
    if ($rgb='b' || $rgb='blue') {
        return hexdec($color_blue);
        }
    }

If you like finding new functions, you should definitely take a look at the php function reference. By the way, I love discovering things in languages too.

Hi, any more suggestions for sample scripts to make?
I've just added a site security tester script.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.