Skip to content

Instantly share code, notes, and snippets.

View girvan's full-sized avatar
Hello World!

Hi girvan

Hello World!
View GitHub Profile
<?php
$url_arr=Array('software'=>'software.sopili.net','dev'=>'dev.sopili.net');
foreach($url_arr as $key=>$value){
echo $key."<br>"; //重點是 key,有時候非常的需要key這個值,然後是字串型態
}
<?php
//宣告
var url_arr={'software':'software.sopili.net','dev':'dev.sopili.net'};
//讀取
for(var key in url_arr){
//這裡面的key值,就真的是字串了!
document.write(url_arr[key]+'<br>');
}
<?php
function mb_str_split($string,$string_length=1) {
if(mb_strlen($string)&gt;$string_length || !$string_length) {
do {
$c = mb_strlen($string);
$parts[] = mb_substr($string,0,$string_length);
$string = mb_substr($string,$string_length);
}while(!empty($string));
} else {
<input type='button' onclick="window.location.href='http://tools.sopili.net/';" value='執行' />
<a style='display:none' href='http://tools.sopili.net/' id='exe'>&amp;amp;nbsp;</a>
<input type='button' onclick="document.getElementById('exe').click();" value='執行' />
<script type='text/javascript' src="http://yui.yahooapis.com/2.6.0/build/yahoo/yahoo-min.js" ></script>
<script type='text/javascript' src="http://yui.yahooapis.com/2.6.0/build/event/event-min.js" ></script>
<script type='text/javascript'>
YAHOO.util.Event.onDOMReady(function(){
});
</script>
<form accept-charset="Big5" method=post>
.....
</form>
<html>
<head>
<script type='text/javascript' src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script>
$(document).ready(function(){
var tpl_html=$('#tpl').html();
$("#main").html(tpl_html); //copy html into new div
$("#tpl input[name='xxx']").val('hi'); //set value into input element
alert($("#tpl input[name='xxx']").val()); // input element is 'hi'
alert($("#tpl").html()); //print #main 's html, where is 'hi' ??
<?php
$counter_file='count.txt';
$count=intval(file_get_contents($counter_file));
$handle=fopen($counter_file,'w+');
fwrite($handle,$count+1);
fclose($handle);
<?php
$counter_file='count.txt';
$counter_tmp='count.tmp';
$handle=fopen($counter_tmp,'a+');
fwrite($handle,'.');
fclose($handle);
$count= intval(file_get_contents($counter_file))+filesize($counter_tmp);