Jump to content

Search the Community

Showing results for tags 'php coding help'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Dear All PHP Master, Kindly need your help (I'm sorry my Bad English), I'm new in PHP and OOP in PHP please help to check I have class to convert number to words below, but when I'm running it the result in browser is error with error message : Notice: Undefined variable: str in C:\xampp\htdocs\latihan\oop.php on line 16 Notice: Undefined variable: str in C:\xampp\htdocs\latihan\oop.php on line 14 Notice: Undefined variable: str in C:\xampp\htdocs\latihan\oop.php on line 16 seratus dua puluh tiga juta empat ratus lima puluh enam ribu tujuh ratus delapan puluh sembilan here it's my code to convert number to words : <?php Class Terbilang { Public function terbilang() { $this->dasar = array(1=>'satu','dua','tiga','empat','lima','enam','tujuh','delapan','sembilan'); $this->angka = array(1000000000000,1000000000,1000000,1000,100,10,1); $this->satuan = array('triliun','milyar','juta','ribu','ratus','puluh',''); } Public function eja($n) { $i=0; while($n!=0){ $count = (int)($n/$this->angka[$i]); if($count>=10) $str .= $this->eja($count). " ".$this->satuan[$i]." "; else if($count > 0 && $count < 10) $str .= $this->dasar[$count] . " ".$this->satuan[$i]." "; $n -= $this->angka[$i] * $count; $i++; } $str = preg_replace("/satu puluh (\w+)/i","\\1 belas",$str); $str = preg_replace("/satu (ribu|ratus|puluh|belas)/i","se\\1",$str); return $str; } } $bilangan = new Terbilang; echo $bilangan -> eja(123456789); //shouldbe show :seratus dua puluh tiga juta empat ratus lima puluh enam ribu tujuh ratus delapan puluh sembilan ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.