473,386 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

converting code using Java Vector to PHP

I've been given the task of converting some existing java code to PHP
so we can integrate it into our web based product.

The problem I'm facing is that the java code makes heavy use of Vector
objects to hold data. This in itself isn't a problem however the java
code makes heavy use of Vector.insertElementAt(). This method inserts
into the vector container at a desired location and shifts the indexes
of all the other items accordingly as necessary.

I don't see any way to really emulate this behavior in with PHP
arrays.

Any thoughts?

....
Krick
Jul 17 '05 #1
2 2110
On 29 Sep 2004 13:21:37 -0700, wk****@gmail.com (William Krick) wrote:
I've been given the task of converting some existing java code to PHP
so we can integrate it into our web based product.

The problem I'm facing is that the java code makes heavy use of Vector
objects to hold data. This in itself isn't a problem however the java
code makes heavy use of Vector.insertElementAt(). This method inserts
into the vector container at a desired location and shifts the indexes
of all the other items accordingly as necessary.

I don't see any way to really emulate this behavior in with PHP
arrays.

Any thoughts?


http://uk.php.net/manual/en/function.array-splice.php , see final example.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2
William Krick <wk****@gmail.com> wrote:
I've been given the task of converting some existing java code to PHP
so we can integrate it into our web based product. The problem I'm facing is that the java code makes heavy use of Vector
objects to hold data. This in itself isn't a problem however the java
code makes heavy use of Vector.insertElementAt(). This method inserts
into the vector container at a desired location and shifts the indexes
of all the other items accordingly as necessary.


$input = array("red", "green", "blue", "yellow");
array_splice($input, 3, 0, "purple");
// $input is now array("red", "green",
// "blue", "purple", "yellow");

http://www.php.net/manual/en/function.array-splice.php

hope this helps

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Salil Das | It's ok to kiss a fool,
bugs@cc | It's ok to let a fool kiss you,
| but never ever let a kiss fool you.
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
67
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. ...
24
by: cs_hart | last post by:
I have an application in Java that I would like to port to c++ to integrate with existing c++ app. Is anyone aware of any tools to help? I found microsft has a java->c# convert, but the java app...
13
by: ppateel | last post by:
Hi, I am new to c++ and I am converting a c program to c++. I changed malloc call to new and I am getting an exception violation. Here is the relevant piece of code. Compiler vc++ 7.0 (.Net...
3
by: fakeprogress | last post by:
How would I go about converting this C code to C++? /* LIBRARY is an array of structures */ /* This function compares 'tcode' with */ /* existing codes in the array. */ /* It...
12
by: steven acer | last post by:
hello, i have a java app that constructs an xml from a specific file format and vice versa. i've been asked to convert it to c++, but im not an expert in c++, actually im mere beginner you can...
2
by: CoreyWhite | last post by:
Problem: You have numbers in string format, but you need to convert them to a numeric type, such as an int or float. Solution: You can do this with the standard library functions. The...
1
by: java4life | last post by:
Java problem -------------------------------------------------------------------------------- I need to generate the following output with a TestProgram. Lecturer 65374 has 3 students:...
10
by: Curious | last post by:
A business associate told me that I should be able to run C++ code in C#.NET environment because C++ and C# belong to the same family. He sent me the code below and asked me to run in C#.NET...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.