473,513 Members | 2,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create an Array Code Help

2 New Member
I have the following code:

Expand|Select|Wrap|Line Numbers
  1. $cPath_new_a = $categories['categories_id']. ",";
  2. $cPath_new_b = $cPath_new_a; 
  3.  
  4. $cPath_new_c = rtrim($cPath_new_b , ',');  
  5.  
  6. echo $cPath_new_c; 
  7.  
$categories['categories_id'] pulls a sub category ID out of the database based on what main category the user is in. Let's say I am in a main category with 2 subcategories, 23 and 53. $categories['categories_id'] alone echos 2353. I want to make this into an array that contains 23 and 53.

I thought the best way to accomplish this would be to add a , to make the string 23,53, then remove the last , then use explode(); to convert the comma delimited string into an array. However rtrim/substr both are not working for me.Using rtrim (see code above) outputs 2353, I also get the same result using substr. Is there some way to convert $cPath_new_a into an actual string within the code (not a dynamic variable) then apply rtrim or substr? Or am I approaching this whole thing incorrectly?

I really appreciate any feedback.
Jun 21 '07 #1
4 1107
DeMan
1,806 Top Contributor
Hi andyy15,

Welcome to thescripts. This looks to me suspiciously like database code, and I hoped you could help me out with which technology you were using. If you can, we can (possibly) move this thread to a specific forum where the experts will be better able to address your enquiry.
Jun 21 '07 #2
andyy15
2 New Member
My Apology, I am using PHP. Please move my thread to the appropriate forum.

Thanks
Jun 21 '07 #3
DeMan
1,806 Top Contributor
Consider it Done!! (Thank-You : Boy was I wrong on the DB)
Jun 21 '07 #4
pbmods
5,821 Recognized Expert Expert
Heya, andyy15.

How are you fetching your results from the database? Every DAL that I've ever worked with (even the non-existent ones) automatically returns its results in the form of an array because of the way mysql_fetch_assoc() returns results.
Jun 22 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
8823
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I want my users to be able to select a report, click on a command button on a form, which will then automatically create the report as a pdf file and...
5
1899
by: Mountain Bikn' Guy | last post by:
How would I do this? public sealed class UtilityClass { public static MyObject Object1;//see note below about importance of static object names in this class public static MyObject Object2; // ... public static MyObject Object400;
8
2228
by: ASP Yaboh | last post by:
I have an ArrayList of data gathered from a database. I want to create a web page from this data by creating a <table>, each cell in each row displays the appropriate data. One of those cells in each row needs a <textarea> control. The background supporting classes are completed, the only task left now is to create the web page. I am at a...
1
1497
by: dadevil | last post by:
Hi guys, this is my first post around here, and here it goes I need to create an array to store info about a number "n" of persons, so i create this structure ( each person have one name and one adress) __value stuct person{ // is this correct? ("__value") string name; string adress; }
23
7367
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these in an array. The application compiles but aborts without giving me any useful information. What I suspect is happening is infinite recursion....
1
1329
geo039
by: geo039 | last post by:
Okay I have an application, which is to demonstrate the use of a created class. I have a previous and next button which cycles through the array. However I need the user to be able to create a new instance of the object then as they cycle through they see their new object. I am stuck on this part. I've tried a few things for my button create event...
10
3941
by: SM | last post by:
Hello I'm trying to create a multi dimensional array in JavaScript, but after some reading i still can't figure out how to apply it to my model. Here it is: I have a list A and for each item in the list A i want to associate an undetermined number of items. The complication for me is the fact that the items to associate in list A are...
4
3810
Ispep
by: Ispep | last post by:
Hi, unfortunately having a bit of difficulty with a question from an Open University course I'm currently doing. If you could help me out in any way I'd be grafeul (though obviously it goes without saying I'm not asking you to solve the question - that won't help come exam time :(). Anyway I have a CSV delimited file in the following format; ...
4
8261
by: sirjohnofthewest | last post by:
If I possessed the power to sway the mind of every user in the world to delete all forms of Internet Explorer I would die a happy man. Hi guys, I frequently visit this site to get answers to my problems and this one is really getting to me... I have a page that allows you to Browse Authors. There are three drop down boxes that auto-populate...
3
4831
by: David K in San Jose | last post by:
I'm using managed (CLR) C++ in VS2005 to create a Windows app that contains a form named "MyForm". In the code for that form I'm trying to invoke some static functions by using an array of function pointers (delegates). I assume I need to use the array< T keyword to allocate an array of delegates, and then initialize the array by setting each...
0
7270
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7565
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7128
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5103
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4759
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3255
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3242
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.