![]() |
|
#1
|
|||
|
|||
Extra null element in an arrayHello forum,
I've got a little bug I haven't seen before. I'm reading a list of collocations (phrases of two or more words) from a file and exploding the file string into an array. So far so good. The collocations are phrases whose components are separated by underscores (_) instead of spaces. Here are some examples of the collocations I'm reading into my collocation array. (Hyphens are also permitted.) 12-tone_music 12-tone_system 14_july Then, I run through each element in my COLLOCATION array and separate each collocation into a COMPONENT array. I wrote my script to read each character in the collocation string and do the following: 1. If character is not a "_" and not a "-", concatenate character to a temporary word variable 2. Else, once an underscore or hyphen is found, save the concatenated word to a COMPONENT array ($aryComp). This is what I would like to see for, say, 12-tone_music: PHP Code:
What I'm finding, however, is that my arrays look like this: PHP Code:
It doesn't matter where the underscore is in a collocation, if it is between the 1st and 2nd component, or the 2nd and 3rd component, and so on. Does anyone know of any problems with the underscore and php files or arrays? Thanks, Samtediou |
|||
|
#2
|
||||
|
||||
Splitting a string into arrays - using preg_split()It's hard to say without looking at your code or function that handles the 'splitting' of those strings...
Here's what I would suggest: PHP Code:
__________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#3
|
|||
|
|||
Great!!Thanks JdS,
Much better now. |
Recent GIDBlog
Install Adobe Flash - Without Administrator Rights by LocalTech
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Sorting a 2D array c++ | mike3340 | C++ Forum | 4 | 15-Dec-2003 14:35 |
| deleting from an array | ionyka | C++ Forum | 1 | 02-Sep-2003 04:09 |
| join problem | zuzupus | MySQL / PHP Forum | 0 | 14-Aug-2003 06:11 |
| MySQL Syntax Error | DropZite | MySQL / PHP Forum | 3 | 09-Jul-2003 05:00 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The