Check if key array is exist with function array_key_exists
Syntax
Syntax
function getLink($url){
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,$url);
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,0);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$result = curl_exec($curl_handle);
curl_close($curl_handle);
return $result;
}
$file_contents = getLink("http://sample-site.com");
$data = array();
preg_match_all('/<div class=\"abc\">(.*?)<\/div>/s',$file_contents,$data);
foreach($data[1] as $idx=>$valx){
$detail1 = array();
preg_match_all('/<a href=\"(.*?)\"(.*?)<\/a>/s',$valx,$detail1);
$link = $detail1[1][0];
echo $link;
}
<html>
<head><title>Sample Title</title></head>
<body>
<div class="abc"><a href="http://google.com" title="Google">Google</a></div>
<div class="abc"><a href="http://yahoo.com" title="Yahoo">Yahoo</a></div>
<div class="abc"><a href="http://facebook.com" title="facebook">Facebook</a></div>
</body>
</html>
preg_match_all('/<div class=\"abc\">(.*?)<\/div>/s',$file_contents,$data);
| Regular Expression | Will match... |
| foo | The string "foo" |
| ^foo | "foo" at the start of a string |
| foo$ | "foo" at the end of a string |
| ^foo$ | "foo" when it is alone on a string |
| [abc] | a, b, or c |
| [a-z] | Any lowercase letter |
| [^A-Z] | Any character that is not a uppercase letter |
| (gif|jpg) | Matches either "gif" or "jpeg" |
| [a-z]+ | One or more lowercase letters |
| [0-9\.\-] | Аny number, dot, or minus sign |
| ^[a-zA-Z0-9_]{1,}$ | Any word of at least one letter, number or _ |
| ([wx])([yz]) | wy, wz, xy, or xz |
| [^A-Za-z0-9] | Any symbol (not a number or a letter) |
| ([A-Z]{3}|[0-9]{4}) | Matches three letters or four numbers |
var fruits = ["Banana", "Orange", "Apple", "Mango"];fruits.push("Kiwi")
var y = [1, 2, 3];
var removeItem = 2;
y = jQuery.grep(y, function(value) {
return value != removeItem;
});
orvar y = [1, 2, 3];
var removeItem = 2;
y.splice( $.inArray(removeItem, y), 1 );
orvar y = [1, 2, 3];
y.remove(2);
function redirect_post($url, array $data) {
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function closethisasap (){
document.forms["redirectpost"].submit();
}
</script>
<body onload="closethisasap();">
<form name="redirectpost" method="post" action="<? echo $url; ?>" >
<?
if (!is_null($data)) {
foreach ($data as $k => $v) {
echo '<input type="hidden" name="'.$k.'" value="'.$v.'"> ';
}
}
?>
</form>
</body>
</head>
</html>
<?
exit();
}
function fx_terbilang($bilangan){
$bilangan = abs($bilangan);
$angka = array("Nol","satu","dua","tiga","empat","lima","enam","tujuh","delapan","sembilan","sepuluh","sebelas");
$temp = "";
if($bilangan < 12){
$temp = " ".$angka[$bilangan];
}else if($bilangan < 20){
$temp = terbilang($bilangan - 10)." belas";
}else if($bilangan < 100){
$temp = terbilang($bilangan/10)." puluh".terbilang($bilangan%10);
}else if ($bilangan < 200) {
$temp = " seratus".terbilang($bilangan - 100);
}else if ($bilangan < 1000) {
$temp = terbilang($bilangan/100). " ratus". terbilang($bilangan % 100);
}else if ($bilangan < 2000) {
$temp = " seribu". terbilang($bilangan - 1000);
}else if ($bilangan < 1000000) {
$temp = terbilang($bilangan/1000)." ribu". terbilang($bilangan % 1000);
}else if ($bilangan < 1000000000) {
$temp = terbilang($bilangan/1000000)." juta". terbilang($bilangan % 1000000);
}
return $temp;
}
$number="";
for($i=1;$i<=100;$i++){
$number.=($i.",");
}
$number=substr($number,0,strlen($number)-1);
$url = "http://192.168.2.201/form/Download?uid=".$number."&sdate=2013-09-10&edate=2013-09-10";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
$data = array();
$record = explode("\n",$server_output);
foreach($record as $r){
$r = str_replace("\t"," ",$r);
$isi = explode(" ",$r);
array_push($data, $isi);
}
print_r($data);
ALTER TABLE yourtable ADD COLUMN id2 INT(11) UNSIGNED NOT NULL AFTER `id`; SET @a:=0; UPDATE yourtable SET id2=@a:=@a+1 ORDER BY id; ALTER TABLE yourtable DROP id; ALTER TABLE yourtable CHANGE id2 id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY(id);
CREATE TABLE yourtable (x INT(8) ZEROFILL NOT NULL, y INT(8) NOT NULL);
INSERT INTO yourtable (x,y) VALUES
(1, 1),
(12, 12),
(123, 123),
(123456789, 123456789);
SELECT x, y FROM yourtable;
TRUEif the givenkeyis set in the array.keycan be any value possible for an array index.<?php
$search_array = array('first' => null, 'second' => 4);
// returns falseisset($search_array['first']);
// returns truearray_key_exists('first', $search_array);?>