Jump to content

Reinoud

Members
  • Posts

    7
  • Joined

  • Last visited

Posts posted by Reinoud

  1. Hi,

    I try to use a python script what give stable solutions for the roommate problem. I have found this script: path to github.

    I get it to run from php with 

    $output1 = exec(. /stableroomate.py   ./solution_prefs.csv  2>&1", $output2)
    var_dump ($output1);

    But I get an error: string(27) "SyntaxError: invalid syntax" Array ( [0] => File ".stableroomate.py", line 170 [1] => holds = dict( (name, None) for name in prefs.keys() ) [2] => ^ [3] => SyntaxError: invalid syntax )

    This refers to python (see attached stableroomate.py) 

    # holds
        holds = dict( (name, None) for name in prefs.keys() )

     

    What is wrong with this syntax? I tried to contact the author and  the university where this came from, but there is little response. I am not familiar with python.

    Help here is greatly appreciated. 

     

    README.md solution_prefs.csv stableroomate.py

  2. OK, but what part of  $string = 1,2,3,4,5]  is not wanted? In your $txt I shpuld remove 'A long string 'right?

    I see that the little program did not copy right here is teh version:

    <!DOCTYPE html>
    <html>
    <body>

    <?php
    echo "why can not I explode array like  0->1, 1->2, 2->3 ..".'<br>';
    ?> 
    <script> 
    var a= [1,2,3,4,5]
    </script>
    <?php
    $a= "<script> document.write(a) </script>";
    var_dump ($a);
    $a_exploded= explode(', ', $a);
    echo '<br> $a_exploded=>'; 
    var_dump ($a_exploded);

    ?>

    </body>
    </html>

  3. I have this little program:

    <!DOCTYPE html>
    <html>
    <body>

    <?php
    echo "why can not I explode array like  0->1, 1->2, 2->3 ..".'<br>';
    ?> 

    </body>
    </html>

    The output:

    why can not I explode array like 0->1, 1->2, 2->3 ..
    input script var total = [1,2,3,4,5];
    what I got with \ document.write(total) \ :1,2,3,4,5
    exploded array var_dump: array(1) { [0]=> string(40) "1,2,3,4,5" } so why does not explode the string in an array?

    This says it all!

×
×
  • Create New...