So I am trying to remove line feed within an array but not cariage returns. Having trouble using array walk, the ltrim function is not working. I need to remove ONLY the line feed("\n") not the cariage return("\r") so using trim will not work. I tried setting the chr(10) and still not working. Any idea's $array = array( [0] => array(C1TEXT => 0001), [1] => array(C1TEXT => 0002), [2] => array(C1TEXT => \n), [3] => array(C1TEXT => \r), [4] => array(C1TEXT => 0003), [5] => array(C1TEXT => 0004), [6] => array(C1TEXT => 0005), [7] => array(C1TEXT => \n), [8] => …

Member Avatar
Member Avatar
+0 forum 4

Hi, I've got a class in PHP with an array of objects in it. I need to loop through these objects and call 2 methods on them but I'm not sure of the best approach. When dealing with arrays, if you use foreach, you can't seem to update the actual array. Example: $foo = array ("first","second","third"); $x=1; print_r ($foo); foreach ($foo as $current){ $current = $x++; } print_r ($foo); outputs the following: Array ( [0] => first [1] => second [2] => third ) Array ( [0] => first [1] => second [2] => third ) so if $foo contains …

Member Avatar
Member Avatar
+0 forum 6

Hi! I am learning C, and am at very introductory level, using this book called C Programming: A Modern Approach. I have just studied about arrays, and while tackling the programming exercises,i got stuck in Que 9 in Chapter 8. This is what the question says [INDENT]Write a program that generates a "random walk" across a 10 x 10 array. The array will contain characters (all '.' initially).The program must "walk" from element to element, always going up,down,left, or right by one element. The elements visited will be labelled with the letters A through Z, in the order visited. Here …

Member Avatar
Member Avatar
+0 forum 13

Hi, I'm pretty new to Python. Working in 2.4 due to company restraints. I'm trying to use os.path.walk to work through a tree directory, and perform different actions on the files based on the name of the file. I thought if I used "startwith" it would indicate that files only called "roads." would be processed. Unfortunatly it just goes ahead and processes all the files in the directories. I don't know a better way! Any help would be much appreciated. The code has been simplified to just show this problem. [CODE]import sys, os def treeDir (arg, dirpath, basenames): workspace = …

Member Avatar
Member Avatar
+0 forum 3

This snippet defines a function walk() which generically performs a depth-first traversal of a tree, using preorder, inorder or postorder rules. Here, genericity means here that there are no hypotheses on what the tree nodes are or the implementation of the tree. Walk() only needs an arbitrary object used as a root node and a function generating children 'nodes' for a given 'node'. At any moment during the walk, it exposes the path from the root node to the visited node. Finally, the implementation is fully non recursive, allowing very deep trees to be traversed. IMPORTANT: this snippet needs class …

Member Avatar
Member Avatar
+2 forum 2

I am trying to produce a random walk solution but I get some strange results. Here's the code : [CODE] #include <stdio.h> #include <stdbool.h> #include <stdlib.h> #include <time.h> int main (int argc, const char * argv[]) { // insert code here... char myArray[10][10]; char letters[26] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}; int counter1 = 0; //row int counter2 = 0; //column int direction; //variable to hold the direction of the next move int counter = 0; srand( (unsigned)time(NULL) ); …

Member Avatar
Member Avatar
+0 forum 7

The End.