🔒 Closed PHP codings

Status
Not open for further replies.

Mauwanna0327

Honorary Poster
Hello po Baka po may makatulong sakin para saber activity ko not to be submitted pero need Ng code for checking
 

Attachments

  • 20190329_065747.jpg
    20190329_065747.jpg
    88.3 KB · Views: 29
  • 20190329_065818.jpg
    20190329_065818.jpg
    50.1 KB · Views: 28
Dahil wala akong magawa, pinursigi kong tapusin. Hahaha!
PHP:
<?php

$products = array("Sensodyne-100, CloseUp-150, Colgate-135",
                "Safeguard-80, Protex-50, Kojic-135",
                "Surf-280 ,Ariel-350, Tide-635",
                "Clover-60, Piattos-20, Chippy-35",
                "Jellybean-60, Hany-20, Starr-35");
            
$total = 0;

foreach($products as $value =>  $key) {
    $key = $key . ",";
    $bb = implode(",", $products);
}
$cc = explode(",", $bb);
foreach($cc as $val) {
    $tmp = explode( '-', $val );
    $arr[ $tmp[0] ] = $tmp[1];   
}
$test = array_chunk($arr, 3, true);
echo "<strong>Cheapest:</strong>";
for($i = 0; $i < count($test); $i++) {
    asort($test[$i]);
    foreach($test[$i] as $val => $key) {
       echo " $val-$key ";
        if($test[$i == 1]) {
            $total = $total + intval($key);
            break;
        }
    }
}
echo "<br> <strong>Total</strong>: $total";

Output:
test2.JPG

Kung gusto mo ng paliwanag, sabihin mo lang. Hahaha!
 
Status
Not open for further replies.

About this Thread

  • 6
    Replies
  • 663
    Views
  • 3
    Participants
Last reply from:
toberu

Trending Topics

Online now

Members online
382
Guests online
1,923
Total visitors
2,305

Forum statistics

Threads
2,291,624
Posts
29,071,881
Members
1,210,983
Latest member
shinjiyooo11
Back
Top