PHP Version of FLAMES Ready!

PraveenKumar Purushothaman

PraveenKumar Purushothaman

@praveenkumar-66Ze92 Oct 26, 2024
Hey guys... As discussed at #-Link-Snipped-# the code for Flames using PHP is ready! 😀

PHP Version of the same is ready... 😀

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "https://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Flames by Praveen</title>
    <style type="text/css">
        body, input {font-family: candara, tahoma; font-size: 12px; width: 150px;}
        form div {margin: 5px;}
    </style>
</head>

<body>
<?php
    $flames 
= array(
        
"F" => "Friends",
        
"L" => "Lovers",
        
"A" => "Affectionate",
        
"M" => "Married",
        
"E" => "Enemies",
        
"S" => "Siblings"
    
);
    if(isset(
$_GET["names"]))
        if(
count($_GET["names"])==2)
        {
            
$n1 strtoupper(str_replace(" """$_GET["names"][0]));
            
$n2 strtoupper(str_replace(" """$_GET["names"][1]));
            if(
$n1 == $n2)
                echo 
"<div>Both the names are same!</div>";
            else
            {
                for(
$i 0$i strlen($n1); $i++)
                {
                    if(isset(
$n1[$i]))
                        for(
$j 0$j strlen($n1); $j++)
                            if(isset(
$n2[$j]))
                                if(
$n1[$i] == $n2[$j])
                                 {
                                     
$n1[$i] = $n2[$j] = "/";
                                     break;
                                 }
                }
                
$n1 str_replace("/"""$n1);
                
$n2 str_replace("/"""$n2);
                
$count strlen($n1) + strlen($n2);
                
$flame "FLAMES";
                echo 
"<div>";
                while(
strlen($flame)!=1)
                {
                    
$flame[$count%strlen($flame)] = "/";
                    
$flame str_replace("/"""$flame);
                }
                echo 
"You both are [b]" $flames[$flame] . "[/b]</div>";
            }
        }
        else ;
    else
    {
?>
    <form method="get" action="">
        <div>Enter the Names</div>
        <div><input type="text" name="names[]" /></div>
        <div><input type="text" name="names[]" /></div>
        <div><input type="submit" value="Get Relation" /></div>
    </form>
<?php ?>
</body>
</html>

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • eternalthinker

    eternalthinker

    @eternalthinker-Kvsi5Y Aug 4, 2011

    I was trying to implement FLAMES in python seeing this thread, but then I met with a doubt.
    While counting, we strike the FLAMES letter where the count stopped and start again from the next letter right?

    The above code will start counting from the first letter every time I suppose.
  • PraveenKumar Purushothaman

    PraveenKumar Purushothaman

    @praveenkumar-66Ze92 Aug 4, 2011

    Ah crap!!! 😔 Yeah man... How to make it right??? 😲
  • eternalthinker

    eternalthinker

    @eternalthinker-Kvsi5Y Aug 4, 2011

    In a straightforward way, we'll have to simulate the actual counting using a count variable.
    But I'm sure if we process enough mathematics in our brains, some efficient equation will pop up 😀
  • PraveenKumar Purushothaman

    PraveenKumar Purushothaman

    @praveenkumar-66Ze92 Aug 4, 2011

    Yup... am working on it... But are you sure this one is wrong? 😐 Tried so hard.. 😔
  • eternalthinker

    eternalthinker

    @eternalthinker-Kvsi5Y Aug 4, 2011

    The whole code is nicely written 😀
    But when we do count%strlen, the counting is always starting from the beginning right.
    Or suppose if we stop counting in the middle in a case; that information is not tracked anywhere in the code.
    Just small changes in the counting alone 😀
  • PraveenKumar Purushothaman

    PraveenKumar Purushothaman

    @praveenkumar-66Ze92 Aug 4, 2011

    Thanks ,,, Will add this part and release.. 😁
  • eternalthinker

    eternalthinker

    @eternalthinker-Kvsi5Y Aug 4, 2011

    I just made the python code. It's posted in #-Link-Snipped-#

    The counting logic is slightly changed 😀
  • PraveenKumar Purushothaman

    PraveenKumar Purushothaman

    @praveenkumar-66Ze92 Aug 5, 2011

    eternalthinker
    I just made the python code. It's posted in #-Link-Snipped-#

    The counting logic is slightly changed 😀
    Yes, but I am still in the situation of where to initialize the counter and its value! 😲
  • eternalthinker

    eternalthinker

    @eternalthinker-Kvsi5Y Aug 6, 2011

    praveenscience
    Yes, but I am still in the situation of where to initialize the counter and its value! 😲
    In the python code, I kept track of the position where we stop counting in each iteration.

    If we stop at $pos last time, then the next stopping position will be $pos = ($count + $pos) % strlen($flame)
  • PraveenKumar Purushothaman

    PraveenKumar Purushothaman

    @praveenkumar-66Ze92 Aug 6, 2011

    Dude... Good one... Will try ... Behold... 😁