Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

201
Visualizações
Show blank input array values in array while fetching data Laravel

I have an input which is array

<input type="text" name="review_rate[]" value="{{$rinfo->review_rate}}" class="form-control text-center pay_review_scale_{{$cnts}}">

Now this input is not mandatory so when user doesnt add any value in first row and adds value in second row then it shows only 1 value in controller array

$review_rate= $request->review_rate;
echo "<pre>";
print_r($review_rate);exit; // this shows only second row value when first row value is blank

It shows values like this

Array
(
[0] => etgddddg
)

I want to show blank value also like below

Array
(
[0] => null
[1] => etgddddg
)

Any Suggestions?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

There could be solution putting index into the name of input like this:

<input type="text" name="review_rate[0]" value="" class="form-control text-center pay_review_scale_{{$cnts}}">

<input type="text" name="review_rate[1]" value="{{$rinfo->review_rate}}" class="form-control text-center pay_review_scale_{{$cnts}}">

Then your key is saved so you can get array like

Array
(
[0] => null,
[1] => etgddddg
)
empty($review_rate[0]) //returns true
empty($review_rate[1]) //returns false

Then you can easily deduce that first one is empty.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda