我有一个看起来像的数组:
$diseases= [
['letter' => 'A' , 'options' => "<div ..."],
....
];
我将这封信作为URL中的参数传递给我。有用。但我无法理解如何打印与页面上的字母对应的选项。谢谢你的阅读。
答案 0 :(得分:1)
你可以把它放在会话中:
<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:converters="clr-namespace:CS.Runtime.Crew.Converters"
x:Class="CS.Runtime.Crew.Resources.CrewResourceDictionary" >
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<!--<converters:DateTimeToNullableDateTimeConverter x:Key="DateTimeToNullableDateTimeConverter" />-->
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
<DataTemplate x:Key="workGroupAttributesTemplate">
<Grid>
<controls:ExtendedDatePicker NullableDate="{Binding Attributes[DueDate], Converter={StaticResource DateTimeToNullableDateTimeConverter}}" Grid.Column="1" Grid.Row="4" />
</Grid>
</DataTemplate>
</ResourceDictionary>
或者,如果您想通过表单发送,可以将其序列化:
session_start();
$_SESSION['array_name'] = $array_name;
答案 1 :(得分:0)
尝试这样的事情:
<?php
$diseases = [
'A' => "<div>A</div>",
'B' => "<div>B</div>",
];
$letterAction = isset($_GET['letterAction']) ? $_GET['letterAction'] : ''; //if the letterAction parameter is defined in the URL, then get it's value
if (isset($diseases[$letterAction])) {
//if the letterAction is available in the array, then print it's value
//i.e. isset($diseases["A"]) would return true but isset($diseases["C"]) would return false in this case
echo $diseases[$letterAction];
}
答案 2 :(得分:0)
您可以使用会话来存储要在所有页面上使用的信息:
session_start();
$_SESSION['diseases'] = $diseases; // store information to key data
在您使用的其他页面上:
session_start();
print_r($_SESSION['diseases']);
如果您只想为1个特定页面设置数据,可以使用http_build_query()
$diseases = ['diseases' => $diseases];
$str = http_build_query($diseases);
echo "<a href='yourpage.php?$str'>click</a>";
现在在下一页上您只需使用:
parse_str($_GET['diseases'], $diseases);
print_r($diseases);