how to return data from python to php and display it on php page
<p>My python code gets data from php  it takes value in text_content variable and then execute its script. But i dont understand to how to return back the results to php. help me please.</p>

<pre><code>&lt;body&gt;  
&lt;?php
// define variables and set to empty values

$text_content="";
$hello="";
if ($_SERVER["REQUEST_METHOD"] == "POST") {

$hello = $_POST['text_content'];

 $command="\Users\jonii\AppData\Local\Programs\Python\Python35\python splitter.py $hello ";
exec($command , $out,$ret );
//echo $out;
echo $ret;
    }
?&gt;

&lt;form method="post" action="&lt;?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?&gt;"&gt;  
 &lt;textarea name="text_content" value="&lt;?php echo $text_content;?&gt;" cols="40" rows="4"&gt; &lt;/textarea&gt;

  &lt;input type="submit" name="submit" value="Submit"&gt;  
&lt;/form&gt;


&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>my python file is:</p>

<pre><code>#!/Users/jonii/AppData/Local/Programs/Python/Python35/python
# Import modules for CGI handling
import cgi, cgitb
import nltk
from nltk.tokenize import sent_tokenize, word_tokenize
import sys
print("Content-type:text/html\n")
print("hello")
text_content = ''
for word in sys.argv[1:]:
    text_content += word + ' '
print(text_content)
def sentence_split( text_content ):
    # Add both the parameters and return them."
    print(sent_tokenize(text_content))
    return
    # Now you can call sentence_split function
sentence_split( text_content );
</code></pre>

<p>I think you have got the data, but you're tried to print it as a string, and not an array. Try:</p>

<pre><code>$command="\Users\jonii\AppData\Local\Programs\Python\Python35\python splitter.py $hello ";
exec($command , $out,$ret );
//echo $out;
/*Loop through each line of data returned*/
foreach ($out as $line){
    print "$line\n";
}
echo $ret;
</code></pre>

php python nltk