Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
Web Hosting

Bonsai Boy of New York Bonsai Trees and Accessories

BlueHost Web Hosting

Liquid Web iThemes WordPress Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

DreamHost Web Hosting


getResponse autofunnels

Liquid Web Cloud VPS Hosting

11,144 questions

15,208 answers

573 users

How to print words pyramids from a string (words 0, 0-1, 0-1-2 ... words 1, 1-2, 1-2-3 ...) in PHP

1 Answer

0 votes
$s = "php java c# python c++";
  
$arr = explode(' ', $s);

for ($k = 0; $k < count($arr); $k++) {
    for ($i = $k; $i < count($arr); $i++) {
        for ($j = $k; $j <= $i; $j++) {
            echo $arr[$j] . " " ;
        }
        echo "<br />";
    }
    echo "<br />";
}
 
 
   
/*
run:
 
php
php java
php java c#
php java c# python
php java c# python c++

java
java c#
java c# python
java c# python c++

c#
c# python
c# python c++

python
python c++

c++ 
 
*/

 




answered Sep 6 by avibootz
...