K
K
kolyafat2016-03-14 18:37:14
Arrays
kolyafat, 2016-03-14 18:37:14

Laravel string splitting and issuing in view?

Hello everyone, please help me, I'm completely confused, everything seemed to be elementary, but something needed to cut does not work
Task:
1. I select the% LIKE% array from the database


$find = DB::table('items')
->where('name_item', 'LIKE', '%'.$request->find.'%')
->get();

2. Next, I want to split the values ​​of $find->name_item into parts $array = explode("=",$find->name_item); using the forech loop
3. Next, I want the pieces of the string to appear in the view, but so that these pieces are related to one object of the initial selection
. Tell me, please, criticize, but it doesn’t work, I’ve been doing tricks all day and in no way, by the way, the number of parts, on which splits the string is always different.

similar_text($val,$req, $g);
if (($g>35)&&(preg_match('/[^x]/i',$val)))

this is how I take one of the pieces of one line

similar_text('AaBbVvYgDdeeeeeZhzhZiiiiYiKkLlMmNnoOoPprrSsTtuuUFFHhhhhhshschjyyyyyyyyyyyyyy', $val, $p);
if ($p>0){

like this one more
How and where to save these parts I don’t know, HELP

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrzej Wielski, 2016-03-14
@kolyafat

Learn to articulate your thoughts correctly.
It's hard to figure out exactly what you need.
And so, you have a collection of elements from the base.
In each entity, you have a name_item attribute.
What do you want to do with it?

K
kolyafat, 2016-03-14
@kolyafat

first i break it down

foreach ($find as $f) {
$array = explode("=",$f->name_item);

Then from the resulting array I select only character Cyrillic values
foreach ($array as $key=>$val) {
similar_text('AaBbVvYgDdeEeeFzhZhiiiYyyKkLlMmNnooPprrssTtuuUffHhhhhhhhhhshjyyyyyyyyyyy', $val, $p);
if ($p>0){

Then I select more values ​​by condition
similar_text($val,$req, $g);
if (($g>35)&&(preg_match('/[^x]/i',$val)))

After that, I would like to output this to the template, along with other sample values ​​from the base, corresponding to the string that was split

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question