我试图编写一个基本上从句子中获取“属性”的函数。这些是参数。将此伪代码翻译成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