How to make alignment on console in php

前端 未结 7 741
慢半拍i
慢半拍i 2020-12-23 17:06

I am trying to run a script through command prompt in PHP and trying to show the result in tabular form. But due to different character length of words I am not able to show

相关标签:
7条回答
  • 2020-12-23 17:52

    Just in case someone wants to do that in PHP I posted a gist on Github

    https://gist.github.com/redestructa/2a7691e7f3ae69ec5161220c99e2d1b3

    simply call:

    $output = $tablePrinter->printLinesIntoArray($items, ['title', 'chilProp2']);
    

    you may need to adapt the code if you are using a php version older than 7.2

    after that call echo or writeLine depending on your environment.

    0 讨论(0)
提交回复
热议问题