Reinoud
-
Posts
7 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by Reinoud
-
-
and I have "1,2,3,4,5" , what part should be removed? I do not see any longstrings. Or do you, are they hidden or something.
I see now what the problem is: the php variable does not contain the string but the function returning the string! How do I get this value in php? Should it be posted?
-
and I have "1,2,3,4,5" , what part should be removed? I do not see any longstrings. Or do you, are they hidden or something.
-
output : why can not I explode array like 0->1, 1->2, 2->3 ..
string(36) "1,2,3,4,5"
$a_exploded=>array(1) { [0]=> string(36) "1,2,3,4,5" } -
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> -
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!
-
I am able to retrieve data from a js like this:
<!DOCTYPE html>
<html>
<body>
<script>
var a=[1,2,3,4]</script>
<?php
$ap= "<script> document.write(a) </script>";
print_r ($ap);
$b=explode(',',$ap);
print_r($b);?>
</body>
</html>Result:
1,2,3,4Array ( [0] => 1,2,3,4 )
Why is the array not explode
error in python code
in PHP
Posted
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