次のテキスト文字列があります: "Gardening,Landscaping,Football,3D Modelling"
「 Football 」というフレーズの前の文字列を選択するには、PHP が必要です。
したがって、配列のサイズに関係なく、コードは常に「Football」というフレーズをスキャンし、その直前のテキストを取得します。
これまでの私の(不自由な)試みは次のとおりです。
$array = "Swimming,Astronomy,Gardening,Rugby,Landscaping,Football,3D Modelling";
$find = "Football";
$string = magicFunction($find, $array);
echo $string; // $string would = 'Landscaping'
これについての助けをいただければ幸いです。
どうもありがとう