Jump to content


rascle

Member Since 15 Jan 2009
Offline Last Active Nov 19 2012 01:42 PM

Topics I've Started

Sort Array By Values

19 November 2012 - 12:56 PM

Hi

I have an array (which is an equation) lets say it is
Array ( [0] => 18x [1] => 10x^2 [2] => 17 )

I want to order the array in terms of the value after ^, so that the highest values after ^ are grouped first. Therefore the above array I want it sorted to become
Array ( [0] => 10x^2 [1] => 18x [2] => 17 )
Does anyone have any idea how I would sort it? I have tried using php sort() to no avail.

Thanks,

Rhys

Preg_match help

04 July 2011 - 02:54 PM

Hi,
Basically I am taking some data from a website, and am storing it in a file called dump.text, I am then using preg_match to find a line in the file, that I need to get some variable information from. I have managed to get the file working but cant seem to get the preg_match bit working:
preg_match('/<td><a href="/business/currencies/quote?srcAmt=1&amp;srcCurr=GBP&amp;destAmt=&amp;destCurr=EUR">GBP/EUR<\/a><\/td>\s+
<td\s+class="data changeUp"> \s+
<img\s+width="9"\s+height="10"\s+src="/resources_v2/images/changeUp.gif"\s+\/>(.*?)<\/td>/si', $eurovalue, $euroarray);

does anyone know what is wrong with it, all I want it to do is to find that line and then below that I echo it, however it doesnt display anything (I would expect it to display the line above). I have checked my dump.text file and the it is working from that end. I have added in things such as /'s, \'s and +si, I dont really know what they are for but have used them in previous codes.
Can anyone tell me what I am doing wrong (before you ask I have looked at the php documentation for this but couldnt really see any answer)
Thanks
Rhys

Havent got a clue where to start

21 June 2011 - 01:25 PM

Hi,
I am trying to create some code with either AJAX or preferable JQuery. Basically I want it so that when someone clicks on a link ("Add to Favourites") the JQuery sends the data to a seperate page, using GET and on the current page displays a confirmation message ("Successfully Added to Favourites"). I want this to happen without going to a new page.
I have managed to do this using HTML and PHP but dont know how to go about getting the JQuery to do what I want above. I have looked on Google for tutorials but couldnt find any that fit my criteria.
Does anyone have any ideas what I should do, and if this is even possible?
Thanks
Rhys

Adding files to a HTTP Server

01 June 2011 - 01:18 PM

Hi,
I currently have a home server (my old PC with Apache HTTP Server installed) and a virtual hosting server. I have all my files such as music and word documents on my home server which will be shown by my virtual hosting server which has php files to display the documents.

I was wondering if it was possible to upload files to my home server using some kind of code on my virtual hosting server. This would mean the code can access my external server.
Is this possible? If so can anyone explain how I should do it or some links with tutorials. Also would this be secure and would other people be able to do this (without a password).

I hope this makes sense.
Thanks
Rhys

Problems with preg_match

22 March 2011 - 01:53 PM

Hi
I am using preg_match to look through some data (collected from external source which works fine) and display it.
I have the preg_match to work fine using:
<?php $rhys = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">.......(external website data which works fine)';
preg_match('/<td width="60%" class="dataRegularUlOff">Price<\/td> <td width="40%" class="dataRegularUlOff">([^<]+)</', $work, $matchesarray);
print_r($matchesarray[1]);
?>

However as the string $rhys wont be present in the actual test.php file that contains the preg_match it doesnt seem to work. I have the data going to a file called dump.txt which works fine, and I can send that info to the test.php page and echo that, however if I save the data to a variable like:
<?php
$work = file_get_contents("dump.txt");preg_match('/<td width="60%" class="dataRegularUlOff">Price<\/td> <td width="40%" class="dataRegularUlOff">([^<]+)</', $work, $matchesarray);
print_r($matchesarray[1]);
?>

It doesnt seem to do anything, and the page appears blank. I have tried variations of using fread to try and get it to work, but no luck.
Does any one have any idea why it isnt working?
Thanks
Rhys

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com