$dt = strtotime('10-12-2016');
$dow_numeric = date('D',$dt);
Kết quả : Sat
Trang Chủ
Android
PHP
Chuỗi
Dialog
Clipboard
Spinner
Auto Layout
ActionBar
Intent
Random
SQL
Admod
Version
TextView
Tabhost
Json
ListView
Time Picker
Calendar
Ham
FloatingActionMenu
Button
EditText
Activity
Custom Adapter
Xoay Màn Hình
Wifi & 3G
Lỗi
Fragment
Shape
SMS
Push
FireBase
CheckBox
Mảng
Facebook
Timer
Service
Text To Speech
Recycler View
Search This Blog
Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts
Sunday, December 11, 2016
Thursday, October 27, 2016
Ham - Ham thay the hang loat ki tu
function XuLyDau($chuoi){
$kitudacbiet = array("<p>", "<span>","<br />", "</span>","</p>","<p>","<h3>","</h3>","</hr>","<br>","<blockquote>","<u>","</u>","</blockquote>");
$chuoi = str_replace($kitudacbiet,"",$chuoi);
return $chuoi ;
}
$kitudacbiet = array("<p>", "<span>","<br />", "</span>","</p>","<p>","<h3>","</h3>","</hr>","<br>","<blockquote>","<u>","</u>","</blockquote>");
$chuoi = str_replace($kitudacbiet,"",$chuoi);
return $chuoi ;
}
PHP - Thay the ki tu
$kitudacbiet = array("<p>", "<span>","<br />", "</span>","</p>","<p>");
$chuoi = str_replace($kitudacbiet,"",$chuoi);
$chuoi = str_replace($kitudacbiet,"",$chuoi);
PHP - Lay du lieu tu data
$English = mysql_query(" SELECT * FROM `huy_tn_cautienganh`");
$mang = array();
while($row = mysql_fetch_array($English)){
$id = $row["ID"];
$HinhCauHoi = $row["HinhCauHoi"];
$DapAnA = $row["DapAnA"];
$DapAnB = $row["DapAnB"];
$KetQua = $row["KetQua"];
array_push($mang, new CauHoiEnglish($id, $HinhCauHoi, $DapAnA, $DapAnB, $KetQua));
}
$mang = array();
while($row = mysql_fetch_array($English)){
$id = $row["ID"];
$HinhCauHoi = $row["HinhCauHoi"];
$DapAnA = $row["DapAnA"];
$DapAnB = $row["DapAnB"];
$KetQua = $row["KetQua"];
array_push($mang, new CauHoiEnglish($id, $HinhCauHoi, $DapAnA, $DapAnB, $KetQua));
}
Sunday, August 28, 2016
Chuỗi - Loại bỏ ra khỏi chuỗi php
$string = preg_replace("/\s| /",'',$string);
Tuesday, July 12, 2016
PHP - Chiều dài mảng (Array)
<?php
$a[0] = 1;$a[1] = 3;$a[2] = 5;$result = count($a);// $result == 3
?>
$a[0] = 1;$a[1] = 3;$a[2] = 5;$result = count($a);// $result == 3
?>
PHP - Hàm xét có phải là số hay không is_numeric() và get_numeric()
get_numeric('3'); // int(3)
is_numeric(nhut); // sai
is_numeric(3); // đúng
is_numeric(nhut); // sai
is_numeric(3); // đúng
Monday, June 27, 2016
PHP - Chuyễn tới đường link khác
<?php
header('Location: http://www.example.com/');
?>
header('Location: http://www.example.com/');
?>
Friday, June 24, 2016
Chuỗi - Thay thế kí tự này bằng kí tự khác bằng preg_replace PHP
<?php
$chuoi= '0 9 4 6 2 4 8 0 1 7';
$timtrongchuoi= '7' ;
$kitumuonthaythe = '9' ;
echo preg_replace($timtrongchuoi, $kitumuonthaythe, $chuoi);?>
Kết quả :
0 9 4 6 2 4 8 0 1 9
$chuoi= '0 9 4 6 2 4 8 0 1 7';
$timtrongchuoi= '7' ;
$kitumuonthaythe = '9' ;
echo preg_replace($timtrongchuoi, $kitumuonthaythe, $chuoi);?>
Kết quả :
0 9 4 6 2 4 8 0 1 9
Chuỗi - Cắt chuổi tham khảo preg_split PHP
<?php
$str = 'hypertext language programming';
$chars = preg_split('/ /', $str, -1, PREG_SPLIT_OFFSET_CAPTURE);
print_r($chars);
?>
$str = 'hypertext language programming';
$chars = preg_split('/ /', $str, -1, PREG_SPLIT_OFFSET_CAPTURE);
print_r($chars);
?>
Array
(
[0] => Array
(
[0] => hypertext
[1] => 0
)
[1] => Array
(
[0] => language
[1] => 10
)
[2] => Array
(
[0] => programming
[1] => 19
)
)
Chuỗi - Cắt các kí tự đặc biệt ra khỏi chuỗi bằng preg_split() PHP
<?php
$keywords = preg_split("/[\s,]+/", "hypertext language, programming");print_r($keywords);?>
$keywords = preg_split("/[\s,]+/", "hypertext language, programming");print_r($keywords);?>
Array
(
[0] => hypertext
[1] => language
[2] => programming
)
Chuỗi - Cắt chuỗi N ký tự bằng str_split() PHP
<?php
$str = "Hello Friend";
$arr1 = str_split($str);$arr2 = str_split($str, 3);print_r($arr1);print_r($arr2);
?>
Kết Quả :
$str = "Hello Friend";
$arr1 = str_split($str);$arr2 = str_split($str, 3);print_r($arr1);print_r($arr2);
?>
Kết Quả :
Array
(
[0] => H
[1] => e
[2] => l
[3] => l
[4] => o
[5] =>
[6] => F
[7] => r
[8] => i
[9] => e
[10] => n
[11] => d
)
Array
(
[0] => Hel
[1] => lo
[2] => Fri
[3] => end
)
Chuỗi - Cắt chuỗi bằng kí tự tùy chọn bằng PHP
<?php
// Ví dụ 1
$traicay = "táo lê mận ổi xoài";
$traicay = explode(" ", $traicay );
echo $traicay [0]; // táo
echo $traicay [1]; // lê
// Ví dụ 2
$data = "foo:*:1023:1000::/home/foo:/bin/sh";
list($user, $pass, $uid, $gid, $gecos, $home, $shell) = explode(":", $data);
echo $user; // foo
echo $pass; // *
?>
// Ví dụ 1
$traicay = "táo lê mận ổi xoài";
$traicay = explode(" ", $traicay );
echo $traicay [0]; // táo
echo $traicay [1]; // lê
// Ví dụ 2
$data = "foo:*:1023:1000::/home/foo:/bin/sh";
list($user, $pass, $uid, $gid, $gecos, $home, $shell) = explode(":", $data);
echo $user; // foo
echo $pass; // *
?>
Chuỗi - So sánh chuỗi trong php
<?php
echo strcmp("Hello","Hello");
echo "<br>";
echo strcmp("Hello","hELLo");
?>
Kết Quả :
0
-1
echo strcmp("Hello","Hello");
echo "<br>";
echo strcmp("Hello","hELLo");
?>
Kết Quả :
0
-1
Chuỗi - So sánh chuỗi trong php
<?php
echo strcmp("Hello","Hello");
echo "<br>";
echo strcmp("Hello","hELLo");
?>
Kết Quả :
0
-1
<?php
echo strcmp("Hello world!","Hello world!")."<br>"; // the two strings are equal
echo strcmp("Hello world!","Hello")."<br>"; // string1 is greater than string
2
echo strcmp("Hello world!","Hello world! Hello!")."<br>"; // string1 is less than string2 ?>
Kết Quả :
0
7
-7
echo strcmp("Hello","Hello");
echo "<br>";
echo strcmp("Hello","hELLo");
?>
Kết Quả :
0
-1
<?php
echo strcmp("Hello world!","Hello world!")."<br>"; // the two strings are equal
echo strcmp("Hello world!","Hello")."<br>"; // string1 is greater than string
2
echo strcmp("Hello world!","Hello world! Hello!")."<br>"; // string1 is less than string2 ?>
Kết Quả :
0
7
-7
Subscribe to:
Posts (Atom)