Push csv enteries into an array
0 Comments Published May 27th, 2009 in PHP, Programming Tags: No Tags.A csv with 2 columns, id and email, will be stored respectively in $x
set_time_limit(300000);
$array2 = file("all.csv");
foreach($array2 as $line)
{
$x[] = list($id[],$email[]) = $line;
}
echo $x[1];
?>
PHP - increment variable name within a loop
0 Comments Published May 26th, 2009 in PHP, Programming Tags: No Tags.PHP - remove/replace special characters
0 Comments Published May 26th, 2009 in PHP, Programming Tags: No Tags.// Provides: Hll Wrld f PHP
$vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U");
$onlyconsonants = str_replace($vowels, "", "Hello World of PHP");
//Good for 'trim' like requirements.
$string = "Here! is some text, and numbers 12345, and symbols !£$%^&";
$new_string = preg_replace("/[^a-zA-Z0-9\s]/", "", $string);
echo $new_string
?>
To run curl with wamp/php make sure you uncomment
extension=php_curl.dll
from php.ini in the php and apache/bin folder.
Comparing 2 csv’s with different columns, maintaining structure and integrity.
example:
| CSV1 NameA,1 NameB,2 NameC,3 NameD,4 NameE,5 |
CSV2 5 1 4 |
$array2 = file("2.csv");
foreach ($array1 as $line1)
{
$cat = str_replace($array2, "XOXO", $line1);
echo $cat;
echo "";
}
Result
| NameA,XOXO NameB,2 NameC,3 NameD,XOXO NameE,XOXO |
sort the second column and delete accordingly, useful for filtering out unsubscribers etc etc
can also use
//prints out existing elements, so result would be 'a' and 'd'
set_time_limit(300000);
$array1 = array('a','b','c','d');
$array2 = array('a','d');
$size= count($array2);
foreach ($array1 as $line1)
{
for($i=0; $i<=$size; $i++)
{
if($line1 == $array2[$i])
{
echo $array2[$i];
echo "<br>";
}
else
{}
}
}
?>
set_time_limit() to whatever many seconds when using array of csv’s etc.
download html page with Curl (Php)
0 Comments Published May 18th, 2009 in PHP, Programming Tags: No Tags.$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$HTML = file_get_contents_curl("http://www.google.ie");

I might actually press on 'send'...

After finally trying out my nike/ipod kit, i was disappointed with the very sluggish website, having to go to a website to check your stat is absolutely ridiculous, after looking around on my ipod i found the location to where the data is stored and to my surprise it was XML ? omg, lolz, wtf ? quite understandable since they have a flash app on their website and obviously easiest way to recognize such data ? xml. Anyway for some reason i had a feeling data would be accessible easily, i was looking forward to writing a parser but this is such a given. Anyway using flex i was easily able to access the data, which is stored in a unique folder for each user, i came across this by asking the user to select the drive and entering the folder,[pic] which is a bit so so, i had to use sharedObjects for this, the whole aspect of this would be an offline version ! but problem being now, each run is stored in a seperate XML ! I had to resort to Air/Flex3 to make use of fileStreams, now i think i can easily use getDirectories to find the unique folder but saying that ive to overcome obstacle off putting it all in one xml but even after that using that data to animate graphs and goal type widgets ? and after all this having to install AIR platform to use this? just as bad as yahoo widgets :/
Anyway i found links to Nike API so it will be easier to just make an online app, think il try both.
EDIT: i just achieved a really important milestone in this project, i can now store the several run .xml files in one .xml file , each ‘run data’ with a separate id tag, AND to think i thought this was impossibly yesterday, i just need to work on displaying infinite data on some flex charts and then we are on to the fun part.
Street Fighter 4
38 Comments Published October 20th, 2007 in Entertainment Tags: SFIII, sfiv, street fighter, trailer, video.
About time !!!! Watch Trailer HERE
Flex 2 : fontSize property
0 Comments Published October 3rd, 2007 in Programming Tags: characters, fit, Flex, fontSize, hbox, length, style, too big, too long, width.
To access the fontSize property of a Label [and i assume Text] component you cant just call LabelID.fontSize. The Flex 2 API clearly puts the fontSize property under the Style category therefore to access this property we must
LabelID.setStyle(”fontSize”,9);.
This comes under great use when text is populated and turns out to be LONGER than expected, in which case LabelID.text.length can be used alongside to tackle this problem.
Another Solution here is to set the width of the Label, with this truncateToFit=”true” is automatically set to on and when the text is longer than expected it is cut off before the stated width and on roll over , the tool tip displays the entire text.
You can view the simple Application here, source here.
Categories |
Categories
|
|||
Latest Photos on Flickr |
||||







