0
나는 trying to use this plugin (여러 조류 (원격) 예제)이지만 백엔드 예제는 php이고 백엔드는 asp.net-mvc입니다. 이 ASP 코드를 asp.net-mvc로 번역하려고합니다.asp.net-mvc 컨트롤러 동작에서 원시 배열을 반환하는 방법
public ActionResult Search(string q)
{
// fetch those from the database
var values = new[] { "value1", "value2", "value3" };
// filter based on the search string the user entered
var result = values.Where(x => x.Contains(q));
// render them to the response
return Content(string.Join("\n", result), "text/plain");
}
및보기에 : 그것은 단지
<?php
$q = strtolower($_GET["q"]);
if (!$q) return;
$items = array(
"Great <em>Bittern</em>"=>"Botaurus stellaris",
"Little <em>Grebe</em>"=>"Tachybaptus ruficollis",
"Black-necked Grebe"=>"Podiceps nigricollis",
"Common Chiffchaff"=>"Phylloscopus collybita",
"House Finch"=>"Carpodacus mexicanus",
"Green Heron"=>"Butorides virescens",
"Solitary Sandpiper"=>"Tringa solitaria",
"Heuglin's Gull"=>"Larus heuglini"
);
foreach ($items as $key=>$value) {
if (strpos(strtolower($key), $q) !== false) {
echo "$key|$value\n";
}
}
?>
나는 이것을 ajax 호출의 뒤에서하려고 애 쓰고있다. 어떻게 PHP가 작동 하는가? – leora
@ooo 결과는 응답에 직접 기록됩니다. –
Darin. 원래 순서대로 키/값 쌍을 렌더링해야한다는 요구 사항 (분류 기준을 알 수 없음)이 필요한 경우 어떤 컬렉션을 사용할 것입니까? 사전은 게재 신청서를 보존하지 않습니다. 그리고 SortedList도 도움이되지 않습니다. 생각? TIA. –