php - show all array before and after my index sign -
could give me advice problem ?
the output is
word no 0 = word no 1 brother = word no 2 see = predicate word no 3 = word no 4 moon =
my question how sign word, if before predicate call subject , after predicate object
word no 0 subject word no 1 brother subject word no 2 see predicate word no 3 object word no 4 moon object
this code
<?php $a = "my brother see moon"; $b = explode(" ",preg_replace("/(\.|\"|,|;|\(|\)|'|)+?/i","",$a)); for($ulangkata=0;$ulangkata<count($b);$ulangkata++) { $kata_kerja = 'see'; $huruf_kecil = strtolower($a); $fungsi_replace = preg_replace("/(\.|\"|,|;|\(|\)|'|)+?/i","",$huruf_kecil); $pecah_untuk_kata = explode(" ",$fungsi_replace); $pecah_kata = $pecah_untuk_kata[$ulangkata]; echo "kata ke - ".$ulangkata." ".$b[$ulangkata]."<br>"; } echo "<br>"; for($ulangkata=0;$ulangkata<count($b);$ulangkata++) { echo $b[$ulangkata]."<br>"; } echo "<br>"; for($ulangkata=0;$ulangkata<count($b);$ulangkata++) { $tmp = $ulangkata; if($b[$ulangkata]==$kata_kerja) { $name = 'predicate'; echo "word no-> ".$ulangkata." -> ".$b[$ulangkata]." = ".$name."<br>"; } else{echo "word no-> ".$ulangkata." -> ".$b[$ulangkata]." = <br>";} } ?>
$text = "you studying when called"
output if have 2 predicate
word no-> 0 -> you= subject word no-> 1 -> were= subject word no-> 2 -> studying= predicate word no-> 3 -> when= word no-> 4 -> she= subject word no-> 5 -> called= predicate
output subject
untill $b[$ulangkata]==$kata_kerja
object
$name='subject'; for($ulangkata=0;$ulangkata<count($b);$ulangkata++) { if ($name == 'predicate') $name = 'object'; elseif($b[$ulangkata]==$kata_kerja) $name = 'predicate'; echo "word no-> ".$ulangkata." -> ".$b[$ulangkata]." = ".$name."\n"; }
output
word no-> 0 -> = subject word no-> 1 -> brother = subject word no-> 2 -> see = predicate word no-> 3 -> = object word no-> 4 -> moon = object
Comments
Post a Comment