Category : foreach

When I am trying to get the TextToSpeech to display the foreach loop, The Text to speech only reads the first part and then stops. function TextToSpeech() { const speech = new SpeechSynthesisUtterance(); let voices = speechSynthesis.getVoices(); let convert = document.getElementById("text").innerHTML; speech.text = convert; speech.volume = 1; speech.rate = 1; speech.pitch = 1; speech.voice = ..

Read more

I’m new to PHP and I tried to print array values vertically but it shows values horizontally. This is the code that I tried. Please help me, guys. $roomCount = count($_POST["room_nos"]); for($i=0;$i<$roomCount;$i++) { foreach($roomsCount as $value){ } $output.= $roomsCount[$i]; } echo $output; Current output is 120122. But I want it as 120 122 Really waiting ..

Read more

i have two multidimensional arrays like this $firstNumbers = $Numbers[0]; $secondNumbers = $Numbers[1]; contents of these arrays are $Numbers[0][0] = 1; $Numbers[0][1] = 2; $Numbers[0][2] = 3; $Numbers[0][3] = 4; $Numbers[0][4] = 5; second array $Numbers[1][0] = 3; $Numbers[1][1] = 4; $Numbers[1][2] = 5; $Numbers[1][3] = 6; $Numbers[1][4] = 7; I need to iterate these ..

Read more

I have an associative array which has the following format: array ( ‘Shopping and fashion’ => array ( ‘childData’ => array ( ‘Beauty’ => array ( ‘childData’ => array ( ‘Cosmetics’ => array ( ‘id’ => ‘6002839660079’, ‘name’ => ‘Cosmetics’, ‘parentName’ => ‘Beauty’, ), ‘Tattoos’ => array ( ‘id’ => ‘6003025268985’, ‘name’ => ‘Tattoos’, ‘parentName’ ..

Read more

Using foreach how I can display the data from an array that looks like this below? Array ( [0] => Person Object ( [_data:Person:private] => Array ( [character] => Akif [credit_id] => 5e4ebbf69a3c49001637a855 [id] => 1489298 [name] => ─░lker Kaleli [gender] => 2 [profile_path] => /xyDXEoTYsbNqW1b7DTtLUZWbs9.jpg [order] => 0 ) ) [1] => Person Object ..

Read more

I want to create arrays within arrays and then fill them up using a function. I want to create array in the following format: array ( 0 => array ( ‘name’ => ‘Shopping and fashion’, ‘id’ => ‘0’, ‘type’ => ‘Interests’, ‘childNodes’ => array ( 0 => array ( ‘name’ => ‘Beauty’, ‘id’ => ‘6002867432822’, ..

Read more

So here’s my code foreach($rekening_tabungan as $tab) { $rata_rata = $this->getSaldoAverageProduct($tab->id_bmt); $pendapatan_product = $this->getPendapatanProduk($rata_rata, $total_rata_rata, $total_pendapatan); $porsi_anggota = $this->getPorsiPendapatanProduct($nisbah_anggota, $pendapatan_product); $total_porsi_bmt += $this->getPorsiPendapatanProduct($nisbah_bmt, $pendapatan_product); foreach($tabungan as $user_tabungan) { dd($rata_rata) if($rata_rata == 0 || $porsi_anggota == 0){ $bagi_hasil = 0; } else { $bagi_hasil = ($this->getSaldoAverageAnggota($user_tabungan->id_user, $user_tabungan->id, ‘tabungan’ )) / $rata_rata * $porsi_anggota; } } } ..

Read more