1

In the laravel how can we made something like this? For example if we write dd($request); in the controller:

 "slug_en" => "english_slug_here"
 "lang_en" => "english"
 "slug_es" => "spanish_slug_here"
 "lang_es" => "spanish"

If i must use "english", simply i can use $request->lang_en; But what if i know just "english" and want to know input name?

$request->X = "english"; 

I want to X right here. I need to set language system with dynamically, but i stuck right here. If can anybody help me, i'll glad so much. Thanks in advance.

2 Answers 2

5

Try this

$x = array_search ('english', $request->all());
Sign up to request clarification or add additional context in comments.

1 Comment

this worked like a charm. I have 2nd question. if we have two input. title and slug for example. Probably these are gonna same. How can we get second input? I mean, title_en="foo", slug_en="foo". Your way is return one of them. How to get second or third? Can we use this like that? array_search('english', $request->all(), 2); ? I hope, i could express myself.
1

use

$x = array_keys ($request->all(),'english');

returns all the keys having value english

if given only the array returns all the keys. The search field is included as a second parameter to get keys for the given search value and there is a optional third parameter strict which may be either true or false, if set strict validation occurstrue

2 Comments

Please chek am1.php.net/manual/en/function.array-keys.php Your answer is wrong
Wrong again. Parameters order.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.