PHP - Array & Thread Using the provided Thread class, show a list of the 3 most
ID: 3780681 • Letter: P
Question
PHP - Array & Thread
Using the provided Thread class, show a list of the 3 most recent visible threads sorted to show the most recently created threads first. Print a JSON response with status code 200 and an array of threads with threadid, title, message and timeposted fields.
HINT: You can nest an array within an array in PHP
ALSO replacing any banned words in the message variable for each thread with ****. The banned words are provided in a string $bannedWords.
HINT: Pay attention to what delimits the words, not the words themselves.
Add your code to threadlist.php. Test your script by running:
threadlist.php
Explanation / Answer
<?php
mThread::listen();
$time = time () ;
$doSleep_response = NULL;
$response2 = NULL;
mThread::start( array( 'doSleep', &$doSleep_response), 10 ,'bijaya' ) ;
mThread::start( 'doSleep1', 10 , 'kulvir' ) ;
mThread::start( 'doSleep2', 10 , 'ajit' ) ;
while ( mThread::runing () ) ;
echo "----------------------<br />" ;
echo "Response Return from doSleep <br />" ;
$result = mThread($doSleep_response);
$json =json_decode($result);
print_r($json);
?>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.