Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Complex Associative Array To XML FIle And Back


We're using php 4.1 and it doesn't seem to have built in support for
this. Coming from a dotnet background this surprised me...Anyways,
thats a different topic altogether...

I'm looking for a php class that can allow me to save a complex
associative array as an xml file on our server and also be able to read
in back into a complex array when needed. (you'll find an example of
the array below). Because of the complexity if the array, I feel it
would be easier to use this method as opposed to saving to a db.

I know i could write a class to do it, but I'm trying not to reinvent
the wheel. Googleing only refers me to extentions like pear which I
dont want. And I 'm sure someone else has had to do this before.

//ARRAY EXAMPLE ...




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Using The $value Of An Associative Array
I am using an associative array to populate one field of a form. I use the $key to obtain the numeric value I want to enter into one of my tables. I use the $value to display in nice text what the numeric key represents. I have no problem entering the $key into the table or displaying the $value on the form. My problem is in displaying the results of the processed form to the user:

My form "action" is "processform". In processform I do the INSERT query and return a message to the user. It is in the message to the user where my problem comes in. I've only captured the $key from the form. How can I capture also the $value from the form post, so that when I display to the user what he or she has chosen on the form, the nice text will display rather than the (to them) meaningless id number? Code:

Associative Array
I have to search a db table, and count distinct records to get some results from a survey we've done. The record needs to be echoed along with the number of times it is recorded. Each field in the table has to be searched individually, so that we can see the answers for each question separately.

I thought that I could do this with one query, maybe 'count distinct', but I couldn't get it to show both the value of the row, and the amount of times that value had been recorded.

So, I have to do 2 queries, one getting the distinct values of the field, the other counting how many times they are recorded. Here's the 2 queries: Code:

Associative Array
I have a list of word/number pairs. I need to retrieve the word that has the highest number associated with it.

I have put this list into an associative array...

$array['apple'] = ཈'
$array['orange'] = Ɖ'
$array['pear'] = ཮'

...and ordered it using arsort() so that "pear" in this case is the first value, then hit a brick wall when I realised that echoing $array[0] didn't work on an associative array. Indeed, why would it? :)

Is there a simple way to retrieve the top value after it's sorted, or do you always need to know the name of the key to manipulate associative arrays?

Else, do I need to look into multidimensional arrays? Something like...

$array[0] = array('apple' => ཈');
$array[1] = array('orange' => Ɖ');
$array[2] = array('pear' => ཮');

At which point, I'm not clear on how this would be sorted based on the values of the nested arrays, and how you would then specify to retrieve the key of the nested array of the first key of the original array!

Passing An Array Of Complex Types From Php Web Service
I have a php web service with a complex type defined. I can pass a single element of this type from server to client and I can also pass an array of this type in but I can't pass an array back out again. A snippit of the code:

Associative Array In Class
In PHP Version 4.3.6 I am trying get a value from a class member that
is an associative array...

class MyClass
{
$var row;

function MyClass()
{
$this->$row = array("A"=>"Apple", "B"=>"Bob");
echo "One: " . $this->$row["A"] . "<br>";
echo "Two: " . $this->row["A"] . "<br>";
$cache = $this->$row;
echo "Three: " . $cache ["A"] . "<br>";
}
}

But this is the output...

One: Array
Two:
Three: Apple

How can I get at the value of the associative array without making a
local copy first!

Array_push() With An Associative Array?
Is there a way to add a key/value pair to an associative array? I'm tryint to do this, but it dosn't work.

$author = array();
while ($row = mysql_fetch_array($result)){
array_push($author,$row[id],$row[name]);}

Associative Array Question - Newbie
I am in the process of designing (before coding) my first serious PHP/MySQL application and I have a question about the best way to store information.

The application will allow users to view the voting record of different legislators. I have concluded that the most efficient way to store the data is in two tables: one that has details about each legislator (mp) and another that has the details of each piece of legislation (bill). Each legislators record will have a field that holds info in an associative array in the form (bill ID, vote result). This way, when a new piece of legislation is added to the database, one more value pair (bill ID, vote result) will be added to each legislators voting record field.

My question is two part:

Is this the most efficient way to store the data?

and

I suspect I will have to be using regular expressions to extract and format the data from the MySQL query. Are there some PHP or MySQL functions or syntax I would find useful in this process of retrieving the data? Any online tutorials? (mysql_fetch_array appears to create an array out of two fields - not really what I am looking for...) I realize this is a rather vague question, but if you have any suggestions, please let me know.

Make Associative Array Out Of String
I have a string that look something like this:

$string = "weight, kg|1200|width, mm|220|prize|20000";

and I would like it to an associative array and print keys and value:

weight, kg: 1200
width, mm: 220
prize: 20000

(The string above is fetched from a database)

Anyone have any bright ideas how to do it?

Adding Values Onto An Associative Array...
I'm trying to develop a simple class which through the interface you can add elements to an array. The method I have used to add the elements is setContentFields($name, $field_type), I have used an array counter variable to increment the array index each time. To me this seems like a workaround, and I wondered if there was a more elegant way of doing this.

The class is as follows:

Sorting An Associative Array Of Objects By Value?
I'm trying to sort an array of objects within an object. Included is a
dumbed down example so that we can get at the meat of the issue without
worrying about complexity or validation. Basically, Funk is an object that
has a name (string) and a value(int). FunkThis represents an object
containing a list of Funks, with each key corresponding to the name of the
Funk. I want to sort this list by val, but I get a Warning: usort():
Invalid comparison function error when I run the script. Keep in mind that
this is for PHP 4

I'm open to suggestions to getting this to work.

<?php
class Funk {
var $name;
var $val;
function Funk($name,$val) {
$this->name = $name;
$this->val = $val;
}
function getVal() {
return $this->val;
}

function getName() {
return $this->name;
}
}

class FunkThis {
var $list;
function FunkThis() {
$this->list = null;
}
function add($funk) {
$this->list[$funk->getName()] = $funk;
}

function compareFunks($a,$b) {
$aVal = $a->getVal();
$bVal = $b->getVal();
if ($aVal == $bVal) return 0;
if ($aVal $bVal) return 1;
if ($aVal < $bVal) return -1;
}

function sortByFunk() {
$list = $this->list;
$this->list = uasort($list,"compareFunks");
}

function show() {
print_r($this->list);
}
}

$a = new Funk("A",3);
$b = new Funk("B",7);
$c = new Funk("C",1);
$d = new Funk("D",9);
$e = new Funk("E",6);

$funkthat = new FunkThis();

$funkthat->add($a);
$funkthat->add($b);
$funkthat->add($c);
$funkthat->add($d);
$funkthat->add($e);
$funkthat->sortByFunk();
$funkthat->show();
?>

[smarty] Addressing Associative Array
Given this assoc array:

$dtl_array[0]['uom_array'][0][0]='key1'
$dtl_array[0]['uom_array'][0][1]='value1'
$dtl_array[0]['uom_array'][1][0]='key2'
$dtl_array[0]['uom_array'][1][1]='value2'
$dtl_array[1]['uom_array'][0][0]='key3'
$dtl_array[1]['uom_array'][0][1]='value3'
$dtl_array[1]['uom_array'][1][0]='key4'
$dtl_array[1]['uom_array'][1][1]='value4'

$sample->assign("dtl_array",$dtl_array);
$sample->display();

How could I create a combobox out of $dtl_array in the templates?
The following does not work:

<select name="aname">
{section name=mm start=0 loop=$dtl_array.0.uom_array step=1}
<option value="{$dtl_array.0.uom_array.mm.0}">
{$dtl_array.0.uom_array.mm.1}
{/section}
</select>

Values From Form Via Associative Array
I have a form which has a text field and a select box. There are many other fields also in the form . I need get the value of the text field or the select box, depending on which one has a value. Additionally it has to give the value only from the text field even if there is a selection made from the select box. I know that i can get post values from form like this: PHP Code:

How To Add An Element To The Middle Of An Associative Array ?
I got an array that consists of elements that are arrays also. Now I
wish I could add an element to the middle of it. Let mi give you an
example:

array (
- array(1,15,apple),
- array(2,28,banana),
- array(3,41,orange)
}

I would like to add, let's say, carrot on 2nd position:

array (
- array(1,15,apple),
- array(2,57,carrot),
- array(3,28,banana),
- array(4,41,orange)
}

Array_splice() does not work (or maybe i use it in a wrong way? - it
splits an adding element for, in that case, 3 elements). Array_push()
adds only to the end of an array. can samobody tell me how to add and
element to the middle of an associative array?

Sort An Associative Array Alphabetically
I am working on a product catalog where it displays a product type on a page via the type variable. The products should be displayed alphabetically by $make and $model and i couldn't find any snippets or info other than asort etc. Just curious if anyone else needed such a sort function and how they did it.

ie: product makes Maico, Madsen, Bio-logic etc and their models MA-300, Itera, AC-200. So I would have listings like Maico MA-300, Maico MA-800, Madsen Itera etc., and I need these alphabetical using make and model values. PHP Code:

How To Print A Multidimensional Associative Array?
I have the following associative array:

$user["john"]["mozilla"]=1;
$user["john"]["xmms"]=1;
$user["doe"]["mozilla"]=0;
$user["doe"]["office"]=1;
$user["paul"]["mozilla"]=0;
$user["paul"]["xmms"]=1;
$user["paul"]["office"]=1;

How can I print such an associative array using a loop statement like foreach?

Setting Values In Associative Array To 0
Ive tried almost every combination of while,foreach, key, value ,
array,0 I can some up with

Ive got an associative array that Ive been using as a counter
eg if (blah blah blah )
{$array['beans']++}
elseif (something else){$array['peas']++}
else {$array['carrots']++}

I then want to reset all the values to zero

foreach ($array as $key=>$value)
{ ??????? }
or array_walk ?



XML Formatted String To Associative Array
I'm working on a php socket server for my chat room, and I need to parse some very short XML messages like this:

<msg t="usr"><body a="pubMsg" u="username"><![CDATA[some message]]></body></msg>

Right now I'm using a bunch of substrings (start laughing. lol), but it's very inflexible. However somehow it works...

The problem arises when I try to store user variables (ignore the indents and line brakes, in reality, there will be non of them; we don't want to waste bandwidth)

<msg t="usr">
<body a="updVar" u="username">
<var t="s" n="varname"><![CDATA[some variable]]></var>
<var t="n" n="someNum"><![CDATA[3]]></var>
</body>
</msg>

I have no idea how to parse those stuff from a string to an associative array... What I want is an associative array that I can access those stuff similar to this way:

echo myXML['firstChild']['firstChild']['firstChild']['attributes']['t'];

and it should output "s"

PHP Stops Processing On Multidimensional Associative Array
When using a multidimensional associative array to cross-reference data
in a second, single-dimensional array, PHP stops processing data after
a few iterations. Memory usage according to the task manager doesn't
seem to spike and CPU usage only gets as high as 11 to 13 percent. A
sample script is provided below, any help or alternative solutions are
welcome. (By the way, the script below works fine on Linux with the
same version of Apache and PHP. Possibly a PHP configuration issue?)

Sorting An Associative Multi-Dimensional Array
I would like to sort array below using the last array of a multi-dimensional array. PHP Code:

Printing Out An Associative Array - Whats Wrong?
I have this code segment:

$query = "Select * from Payments order by CustID";
..
.. /* execute the query */
..
if (ora_exec($cursor))
{
$recordset=array();
while (ora_fetch_into($cursor,$recordset,ORA_FETCHINTO_N ULLS|
ORA_FETCHINTO_ASSOC))
{
echo $recordset["CustID"]."<BR>";
echo $recordset["Amount"]."<BR>";
}
}

Gives me the following error
Notice: Undefined index: CustID
Notice: Undefined index: Amount

The table Payments has only CustID and Amount as attributes. is my
usage of the array offset incorrect?

ODBC: Fetch Results As Associative Array
Will PHP fetch the results of a query using ODBC as an associative array? I know that MySQL does that, but I couldn't find it for ODBC connections.

POST (or GET) Associative Array To Script From Form
Actually thought I understood this but I can't seem to make it happen this morning, and I can't seem to find a clear simple reference here.

Can I pass an associative array from a form (using either POST or GET) to a .php script all at once, in one simple step?

ie. Say I have the following variable/associative array

$graphtable = Array ( [TESTPHASE] => G085 [GRADE] => 3 [0_LE_1_A] => 0 [1_LE_1_A] => 7 [2_LE_1_A] => 28 [3_LE_1_A] => 22 [4_LE_1_A] => 7 [null_LE_1_A] => 0 [PROTOCOLS] => 64 )

And I pass it as a hidden variable in the following form: ....

Complex Php File Script
This is file.txt:
"Something
Something else
Whatever
Nobody
Nobody"

There i have 5 lines. Is there a sciprt which will search this file for What and delete the line where is that string written.

Back Referencing To Get An Array Index?
My website needs to allow users to specify where a thumbnail image will
appear in the text ($articleText) they submit.
The thumbnail filenames are held in a single-dimensional array called
$photos
e.g. the users are to type [thumb4] to specify they want thumbnail four (
from array position 4 )

I was hoping the following expression would work, but it doesn't. The
returned text always includes <img src="thumbs/"> i.e. no image filename is
inserted. (I was expecting something like <img src="thumbs/dave.jpg"> )

$articleText = preg_replace("/[thumb(d+)]/", "<img
src="thumbs/".$photos[$1]."">", $articleText);

Reading An Array Of Records From MYSQL Then "Save As" Them Back As Copy
Hi all,

Ok here is what I want to do then I will show you what I have. I have some records in a MySQL DB that I want to store in an array and then immediately copy them back where the only thing that would change would be one field - the date. So here is my table:
-------------------------------------
|userName | date | value |
--------------------------------------
| theDano | 200005 | 123 |
--------------------------------------
| theDano | 200005 | 345 |
--------------------------------------
| theDano | 200004 | 678 |
--------------------------------------
| joeUser | 199908 | 897 |
---------------------------------------

So if I am querying for the user "theDano" on a specific date (format yyyymm) in this case 200005 (year 2000 month of May)

Here is my array to query all records to fullfill this request:

if ($update=="future")
{
if ($month!="01")
{
$db = mysql_connect("localhost", "dbuser");
if($db)
{
mysql_select_db("dbName",$db);
$result = mysql_query("SELECT * FROM tableName WHERE userName = '$userName' AND date = '$date' ORDER BY value DESC ",$db);
if ($result)
{
$num=mysql_numrows($result);
$i=0;
while($i < $num)
{
$userName = mysql_result($result,$i,"userName");
$value = mysql_result($result,$i,"value");
echo "<tr>";
echo "<td width=Ê×'>" . $userName . "</td>";
echo "<td width=ï`'><div align='right'>" . $value . "</div></td>";
echo "</tr>";
++$i;
}
}
}
}
}

Now I want to take the array of records queried which was:

| theDano | 200005 | 123 |
--------------------------------------
| theDano | 200005 | 345 |

and copy them to look like this back into the database:

| theDano | 200006 | 123 |
--------------------------------------
| theDano | 200006 | 345 |

so you can see that the only thing changed was increasing the month by one. Would seem simple to most but I am having a tough time wirting the code to read the array and increase each date value by "1".

Thank you in advance for anyone that replies. )

Dano

Complex Name Index
I've not found anything that relates to this problem and I posted it and in the MySQL forum and got no replies. Maybe there are more ideas here.

I want to display an alphabetical index from a table where each row contains information about a couple, i.e., lastname, hisfname, herfname, maidenname. The index should display both the man's name and the woman's maidenname in the same list.

Here's a sample of my table:

lastname | hisfname | herfname | maidenname
smith | john | jane | cook
riley | dan | sally | price
bagley | bill | donna | davis
green | graham | susan | richards

From this sample I'd like to extract an alphabetical list like the one below:

bagley, bill
cook, jane
davis, donna
green, graham
price, sally
richards, susan
riley, dan
smith, john

What sort of query could I run to get this order?

Can I use two queries and somehow join them to form a single list? Or is there some PHP algorithm I should employ to derive the list from two queries?

Complex Algorithm
Good afternoon gurus and guru-ettes!
I am searching for an algorithm that will take a list of monetary values
and determine which of these values totals a value supplied to the
widget.

1. I supply a value to the application and give a date range
2. The application will query for all of the values in the date range...

Complex Random
i know it's simple to random selcet an item from anyting ( ie an array ) but lets say i have 5 banners, and i wants to show them randomly, but the thing is i like banner #1 more than the rest, so i wanna show that one the most!

Of course i could put the 5 banners into an array, and the add banner #1 again, and then randomly select one of them, this way #1 will be showed twice as many times as the rest.
but lets say i have 50 banners and banner #2 #5 #10 #11 and #15 is my favorites, then #1 #20 #23 #40 is my second choise and the rest are just plain normal, how could i then make a function where i can weight the selection but they would still be more or less random?

Complex Query
I hope it is easier for you to answer than for me trying to explain
it...

In a database I have some tables , each one has some mandatory fields
at the beginning and a couple at the end.
In the middle each table can have some additional fields from 0 to n
depending on how many fields have been inserted by who created the
table.

Now, I need to set up a script which ,after receiving from a form the
table name, can print the first known fields,and all the additional
ones , but I don' t want it to show the last 2 columns of the table
because they store sensitive or useless contents.

Complex If Statement Search
i'm trying to put together a search of my product database. The user can input into a form to inputs. (side1 and side2). I have a DB that has the following columns:

dosage1, dosage2, dosage3, side1_1, side2_1, side1_2, side2_2, side1_3, side2_3, desciption1, description2, desciption3.

So I'm trying to take the input from the user and compare it like this:

if ((side1 = side1_1 or side2_1) or (side2 = side1_1 or side2_1)) OR if ((side1 = side1_2 or side2_2) or (side2 = side1_2 or side2_2)) OR if ((side1 = side1_3 or side2_3) or (side2 = side1_3 or side2_3))

Then i would like it to be able to out put the corresponding info such as if the info == side1_2 then output dosage2, descrption2.

Complex Rating System
I am looking for suggestions about the best way to track who has voted in a rating system for http://www.designologue.com/ [You may need to take a look at the site to understand what i'm talking about]

Each DSNLG will be rated on the quality of the DSLNG as a whole and then both designers will be rated separately. Only registered members will be able to vote and only vote once on each of these three polls.

Seeing as how there is an undefined number of DSNLGs what would be the best way to track if a member has already voted on which DSNLGs and designers? [I'm not looking for code - just suggestions]

I already have a user_data object and was thinking of adding a tracking system to that in the form of a multidimensional associative array that is then serialized and stored in the database in the same table as the other user data.

When a user visits a DSNLGs page [let's say no. 2] my script would check user_data[rated][2] to see if it contains a true or false in the 0,1, and 2 indexes. if any of those values were false the appropriate rating system would be sent to the browser. if any were true the results of the ratings would be sent.

As the experienced can proly tell i don't have much experience in handling this type of information. If anyone can think of a better way please let's hear it.

Databases And Complex Forms
Got a question for y'all regarding the best way to maintain HUGE forms and
linking them to data tables in MySQL.

I have a set of forms that were created specifically for a Loan Services
Company (ranging from request forms to complex inspection forms with
hundreds of input fields (such as room size, item quantity, item quality and
costs) the problem I had in the initial setup was how to create the
associated data tables for each type of form. I opted to store ONLY the
client information, type of report and a few other miscellaneous items in a
table called reports and the rest of the data is dumped into an INI format
file using a php class that reads and writes ini files.

This current setup works, but not all the fields from the reports are
searchable. Additionally, going this route I had to modify all the forms and
create the associated report format (no form fields, just echoing the
correct data back where needed) and this is not user friendly enough (as if
the forms change, then the report format must change as well). Does anyone
have any recommendations on how best to modify this to use MySQL tables to
store the data without overloading the database? Or am I going about this
the wrong way?


Relatively Complex Php/mysql Queries
I need to write to 5 related mySQL tables from one form, using php.

First, I need to write some of the data to one of the tables so that I can extract (SELECT) the auto_incrementing primary key to use as a foreign key in the next two INSERTS.

Then I have to extract (SELECT) the auto_incrementing primary key from one of those tables to use as a foreign key in the last tables.

But if I get a failure part way through this operation, I could have a partial write and my data integrity is not just compromised... it's just plain bunged up!

What are some strategies that can be used to prevevnt this from happening?

Complex Number Functions
I am looking for a library of functions/objects for doing math with complex(imaginary) numbers. About 10 years ago I found a library of Turbo Pacal functions that had to be adapted for use in a Delphi app to produce fractal graphics.....lost to me know, but similar must still exist!

How To Compare Complex Strings?
i got a DB, in mysql, with more than 12000 records, each record has some values as name, surname, city, zip code and address. My task consists to find all record with the same address. Here is the biggest problem because, while city and zip code are entered with a drop down list, and so there are no possibilities to got differences, the address is entered manually in an input text. Code:

Echo Complex Array's
I've a question about printing complex array's

with print_r $xmlC->obj_data I get this example bellow
But can anybody give me one example on how to echo
$xmlC->obj_data[RDF][0]['Restaurant'][0]['City'][0];
I try'd with combinations like
$xmlC->obj_data[RDF][0]->Restaurant->[0]->City->[0];
But I must be horrobly wrong.

stdClass Object
(
[RDF] => Array
(
[0] => stdClass Object
(
[xmlnsr] =>
http://www.w3.org/TR/1999/REC-rdf-syntax-19990222
[xmlnss] =>
http://www.w3.org/TR/2000/CR-rdf-schema-20000327
[xmlnsd] => http://purl.org/dc/elements/1.0/
[Restaurant] => Array
(
[0] => stdClass Object
(
[id] =>
Afghanistan/Kabul/Anaar_Restaurant1046807280
[Location] => Array
(
[0] => Afghanistan/Kabul
)

[Title] => Array
(
[0] => Anaar Restaurant
)

[Address] => Array
(
[0] => House Number 6,
Street 4
)

[City] => Array
(
[0] => Kabul
)

[Country] => Array
(
[0] => Afghanistan
)

[Phone] => Array
(
[0] => 070 284 315, 070
291 857
)

[CrossStreet] => Array
(
[0] => Kolola Pusta behind
the UNICA guesthouse
)

Complex Search Query
I am doing a (in my view) complex search query. its a school site where you can search a database to see what grades each student got in a selected subject.
i have gave the user the options to select a grade from one drop down menu and select a subject from another drop down menu, the user can also select 'no preference' which will return a value of '0'.

My problem is this... how do you program the script to return all records when value '0' is returned. The user might have no preference to what grade was acheived but want all the grades from maths, the user might want to see all students which received an 'A Grade' with 'no preference' to what subject, OR, the user might want to see all students that recieved 'A Grade' but only for 'maths' subject.

Although i have only mentioned 2 possible search options above (grade and suject) I will be adding more criteria for the user to choose from to help them narrow results. This is where the search becomes complex to me. I have thought of two possible ways to do this:

1) build a search query as i go

2) do an overall search then delete records that do not match the criteria chosen by the user

if i use option 1 then as far as im aware i will have to do 'if statements' for every eventuality. If i use option 2 im a little confused as to how to do it. Does any1 have any idea's how i can make this simple??

I personally am thinking option 2 might be best but i would need to take all records within the database into an array 1st and then delete out only the records that DO NOT match what the user selected (so if the user selected 'A Grade' the code would remove all records from the array where grade IS NOT EQUAL to A).

I also have the problem with doing it this way how i would program the script to return all the results if the no preference value was returned.

Help: Complex Search And Maintenance In MySQL
Constructing a multi-part database search in MySQL e.g. Part 1 delivers IDs 4, 5, 6; Part 2 delivers 12, 1, 34, 8; Part 3 delivers 25, 10, 2, 20, 15.

Want to display the results in a list IN THIS ORDER (i.e. 4, 5, 6, 12, 1, 34, etc.) and be able to display PAGE BY PAGE, e.g. 5 results at a time.

Search itself is quite long and involved , so would prefer not to completely re-do the search for every page.

I have tried the following:

1. Build up search in a temporary table: Holds the order for displaying results, but is lost immediately script terminates, hence cannot display page by page

2. Store ID nos in a string, then pull out and display 5 at a time: Able to maintain between pages in HTML_POST_VARS, but if send the list of IDs to MySQL, order appears to be lost

3. Works if do same as 2. but then retrieve data for IDs one by one. I am concerned this is going to take a long time if many users.

Issues Working With Complex Math
I'm having a little bit of trouble trying to implement some arithmetic
logic into an application that I'm working on, and I'm hoping that
somebody can possibly point me in the right direction. I am working
with a database with ZIP codes, latitudes, and longitudes, and am
working to implement the Haversine formula alongside with another
formula for creating a "box" that I can use to get locations from within
a square (or as close as you can get with the Earth, anyway).

While I was reading up on the math and working through the problem, I
wrote a function (well, two) in the bc calculator language to process
this information manually while initially working with the concepts.
Now that I have a semi-functional understanding of the problem, I
rewrote the logic in PHP, and am having a problem actually computing
longitude portions of coordinates for the "box" that I want to use to
pull data about a given region.

The problem as best as I can tell resides in the latlong_box($lat,
$long, $miles) function that I've written in PHP, but I'm not seeing
anything different, computationally, from what I've implemented in bc;
of course, I could just be suffering from staring at it too long, too.
:-) I'm not sure if I am expecting something that PHP won't provide, or
if I'm handling something not quite right in PHP's arithmetic eyes, or
what, really. The latitudes being computed are correct, it's just the
longitudes that are way off.

I will go ahead and give a link to the code and include a sample run of
the script. I appreciate any help/pointers!

The sample run:
./zip_test.php
Array
(
[zipcode] => 30034
[latitude] => +33.6907570
[longitude] => -084.2511710
[city] => DECATUR
[state] => GEORGIA
[abbr] => GA..

Use Of Complex (Curly Bracket) Syntax
If I use the curly bracket syntax (referred to as the
complex syntax) within a string, how do I get to call a
function within it?

The php manual says that the first (or previous)
character for the curly bracket has to be a dollar sign '$'.
This is fine for variables, arrays and some objects but
doesn't allow me to call a function such as addslashes() or
trim() before I return the string in the variable.

I have tried using assignment, concatenation and even
methods of an instantiated object and have found the parser
refuses to allow the equal '=' sign, fullstop '.', or even a
standard left bracket '(' within the complex curly brackets.
For example, I had expected the following to work:

$x = "";
$string = <<<EOT
This is a text string ...
.... {$x . addslashes(trim($myinput1))} ...
.... {$x . addslashes(trim($myinput2))} ...
more text etc .....
EOT;

It doesn't work, the parser objects to the full stop symbol '.'

Worse still, the following was objected to

$string = "This is text .. {$x->myGetMethod($specifier)} ..
more text etc ";

The refusal to accept a left bracket here means that it is
not a real object oriented language as you can't always get
to objects within complex syntax!

Considering that they have called this the complex syntax, I
think that it is very poorly implemented. My expectation
was that any legal PHP expression should be able to be used
inside the braces so long as it resulted in a string. It is
far from that!

Strangely, I have read (but haven't tried) that the
following expression works:

$string = "This is text {${$result ? 'var1' : 'var2'}} ..
more text etc ";

Can anybody please tell me some way to use a function within
the curly bracket (complex) syntax? (without a discussion
on faults of Heredoc or doing it without the complex syntax)

Complex Image Resizing And Uploading
I'm currently uploading an image from a forms page along with the information to my server and also adding the filename etc to my sql database. I'm checking that the files are only jpg and gif files and that they are less than 3MB in size. I'd like to now resize this image and upload alsoto the same location as the large image but with the extension _small. e.g - largeimage_small.gif

So essentially I'd like to add the large image to the server and also the small resized image (max 150 pixel width). I can find a way of resizing the image by opening it as is below. So far the script for upload the image is working really well. Now I need to have the smaller image version added also. Here's the code:

Sort/limit Question With More Complex Functionality?
can someone suggest a way i might crack the following problem? What i've got so far:

Trouble With Counting New Documents With Complex Query
width formulating the most
effective (in terms of processing time)
SQL query to count all the "new"
documents in the repository, where "new" is
defined as "from 00:00:01 up to 23:59:59
today". My current query does not give me
satisfactory results, it creates a visible
delay in rendering of the main page of one of
the departments (Drugs) :8[[[
(at least I, for now, think it's the culprit).
It's for the <url: https://hyperreal.info >
site, see for yourself, notice the delay
<url: https://hyperreal.info/drugs/go.to/index >.

Currently I ask MySQL to (offending
PHP fragment follows, I hope it is self-
explanatory)....

PHP5 SOAP Complex Data Types
I am having problems passing complex data types from a SOAP server constructed using the built-in PHP5 SOAP extension to a SOAP client using nusoap.php or PEAR::SOAP. Code:

Associative Arrays...help
Is there any way I can construct an associative array out of 3 other arrays?

Associative Arrays
Basically I am writing a shopping cart from scratch. I can get my first item looking good but I can never add to my cart. If I choose another item it seems to overwrite the first one. Code:

Checking File Existence Through A List Of File Locations Gathered From An Array
I've been trying to wrote a code to check the existence of some files gathered from a field in mySql database.

And I am kind a stuck at a point where I get the file locations from the database but when it passes those locations to file exist it keeps telling me the file does not exist.

Only first file exists the other 2 file does not exist to test if the code was working or not. Code:

PHP ADODB DB2 Associative Arrays
I know this doesn't -exactly- match php, but its still related, and
adodb doesn't have its own google group yet, so i thought I'd go
generic.

The problem is, I created a nice little script for Oracle using oci8
and tried to convert to db2, but ran into issues. In case you don't
know what ADODB is, checkout http://adodb.sourceforge.net/

The GetAssoc, or SetFetchMode(ADODB_FETCH_ASSOC) methods to get an
associative array from a DB2 database don't function properly. The
result of a simple query, for example:
select firstname, lastname, dob from person
results in an array something like:
Array (
[LASTNAME] => 'Bob'
[DOB] => 'Henry'
[0] => &#55614;&#57108;-12-01'
)
Now -that- is a real pain, and I've tried looking through the db2
driver, but couldn't pin-point myself where the problem was, as the
ADODB code is a little out of my league, and the complications of the
new 'extension' don't help.

I was just wondering if anyone knows what I'm talking about? Or maybe a
possible solution to the problem? I'd prefer a solution at the base
level, not a 'quick-fix', as I use this library often.

Some further information that might be useful is that i'm running DB2
v8.2 Enterprise, on WinXP (up-to-date). I'm using the latest ADODB
4.8.1 (NOT the extension). And i'm using Apache/2.2.2 + PHP/5.1.4
served on WinXP, same machine as DB2.

Associative Arrays Keys
I have a some text that i have to sort according to their year. The text is in this format..

A Short Story (2000)
A long time ago (1999)
A list (2004)
Before Time (1999)
Car parts (2004)

so basically i want the output to be..

A long time ago (1999)
Before Time (1999)
A Short Story (2000)
A list (2004)
Car parts (2004)

I thought the way to go about this would be to extract the years and put the whole thing in an associative array with the years as keys, but of course the keys have to be unique so in this case values override each other. PHP Code:


Copyright © 2005-08 www.BigResource.com, All rights reserved