如何纠正数组中的显示数据。我猜这是一个foreach循环,但我不知道如何咬它。我只需要标题。在日历表中。
非常感谢!
@foreach($list as $item)
{{ $item->header }}
@endforeach
我尝试了上面的代码,但抛出一个错误,未知值“ header”
@foreach($results as $type => $list)
<div class="single-contact-information mb-30">
<h3>{{ $type }} </h3>
{{ $list }}
</div>
@endforeach
[{"id":1,"header":"test","description":"<p>test<\/p>","date":"2020-12-12"}]
编辑: SearchController:
public function search(Request $request)
{
$search = $request->get('search');
$results = [];
$results['calendars'] = DB::table('calendars')->where('header', 'like', '%'.$search.'%')->get();
return view('pages.search', ['results' => $results]);
}
答案 0 :(得分:1)
您应该尝试以下操作:
string certlocation = Environment.ExpandEnvironmentVariables("%appdata%\\x\\");
X509Store store = new X509Store(StoreName.Root, StoreLocation.CurrentUser);
var ecdsa = ECDsa.Create(); // generate asymmetric key pair
var req = new CertificateRequest("cn=" + certname, ecdsa, HashAlgorithmName.SHA256);
var cert = req.CreateSelfSigned(DateTimeOffset.Now, DateTimeOffset.Now.AddYears(5));
// Create PFX (PKCS #12) with private key
File.WriteAllBytes(certlocation + certname + ".pfx", cert.Export(X509ContentType.Pfx));
// Create Base 64 encoded CER (public key only)
File.WriteAllText(certlocation + certname + ".cer",
"-----BEGIN CERTIFICATE-----\r\n"
+ Convert.ToBase64String(cert.Export(X509ContentType.Cert), Base64FormattingOptions.InsertLineBreaks)
+ "\r\n-----END CERTIFICATE-----");
string cerFileName = certlocation + certname + ".pfx";
X509Certificate2 certificate = new X509Certificate2(cerFileName);
store.Open(OpenFlags.ReadWrite);
store.Add(certificate);
store.Close();
上面的值为json,然后使用以下代码
[{"id":1,"header":"test","description":"<p>test<\/p>","date":"2020-12-12"}]
更新后的答案
$list = [{"id":1,"header":"test","description":"<p>test<\/p>","date":"2020-12-12"}];
@foreach($list as $item)
{{ $item['header'] }}
@endforeach
$list = json_decode($list);
@foreach($list as $item)
{{ $item['header'] }}
@endforeach
答案 1 :(得分:0)
尝试这个
此处使用的json_decode
功能
@foreach(json_decode($list) as $item)
{{ $item['header'] }}
@endforeach