Cara mengambil atau memilih string

This item was filled under [ Code Snippet, PHP ]

Cara untuk mengambil atau memilih atau mencomot kalimat tertentu dari database atau text normal.
Contoh isi pada data adalah: NCABZ-2007
Dan kita ingin mengambil hanya 3 huruf mulai dari digit ke 3 sampai 3 karakter.

How to pick a complex string from MySQL.
We can pick a string from MySQL database with various style.
Example, the value from database is NCABZ-2007
And we want only view ABZ

<?php
$data = "NCABZ-2007";
$new_data = substr($data, 2 , 3);
echo $new_data; // hasilnya: ABZ
?>

hasilnya dari variable $new_data adalah “ABZ

Rate this topic:
1 Star2 Stars3 Stars4 Stars5 Stars (6 votes, average: 5.00 out of 5)
Loading ... Loading ...
Popularity: 3,123 views
Tagged with: [ , ]
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Artikel Sejenis

Leave a Comment

Notify me of followup comments via e-mail. You can also subscribe without commenting.

Halaman ini di eksekusi dalam waktu 1.594 detik! (koneksi mayan bagus nih...)