php - How do you put an array into a string and then index the string using laravel 5 -
ok, i'm running problem i"m trying split/ index values in column in database. put i've been trying put string, , combination have tried should work, everytime try split value keep getting error array string conversion , errors shows database appose string or @ least column. sorry if code @ point looks more work should haha. out of desperation , attempt work.
this controller:
public function fsc_list($id) { $fsg_find_id = fsgdata::find($id); $fsc_list_all = fscdata::all(); $fsc_find_id = fscdata::find($id); $num_match = fscdata::all()->toarray(); $fsc_num_col = fscdata::lists('fsc_number'); $newstring = implode("",$fsc_num_col); $final = $newstring.str_split(0,2); return view('fsc_views.fsc_list', compact('fsg_find_id','fsc_list_all', 'fsc_find_id', 'num_match', 'fsc_num_col', 'newstring','final')); } this view:
@extends('layout.master') @section('content') <div class="figure"><img src="/content/images/figure2.jpg" /></div> <div class="main"> <h2>search results fsg number: {{ $fsg_find_id->fsg_number }}</h2> <ul> @foreach($fsc_num_col $fsc_find_id->fsg_number) @if($fsg_find_id->fsg_number == $final); <a href='/nsn_list={{ $fsc_find_id->id }}'>{{$fsc_find_id->fsc_number}}</a></br> @endif @endforeach </ul> </div> @endsection note goal have 2 numbers chosen users match first 2 digits of bunch of 4 digit numbers in database , grab of meet criteria. in advance can help.
the immediate issue looks line:
$final = $newstring.str_split(0,2); basically, trying combine string $newstring array str_split(0, 2) why getting array string conversion error. take @ manual entry str_split - doesn't understand properly.
if trying first 2 characters of string should using substr. like:
$full_string = 'abcdefg'; $first_two = substr($full_string, 0, 2); # $first_two = 'ab'
Comments
Post a Comment