我試圖編寫一個基本上從句子中獲取「屬性」的函數。這些是參數。將此僞代碼翻譯成PHP
$q = "this apple is of red color"; OR $q = "this orange is of orange color";
$start = array('this apple', 'this orange');
$end = array('color', 'color');
,這是我努力使功能:
function prop($q, $start, $end)
{
/*
if $q (the sentence) starts with any of the $start
and/or ends with any of the end
separate to get "is of red"
*/
}
與代碼本身不僅我會遇到的問題,我也不知道如何進行搜索,如果任何數組值開始於(不僅包含)所提供的$ q。
任何輸入都會有幫助。 謝謝
這種作業的氣味。它應該被標記,如果是這樣的話...... – Endophage 2011-04-16 00:14:21
@Endophahge不會。我真的很想知道如何翻譯。 @ Wh1T3h4Ck5謝謝!會做! – Kartik 2011-04-16 04:24:59