473,413 Members | 1,802 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,413 software developers and data experts.

Removeing blank spaces

KeredDrahcir
426 256MB
I have some values in an array and I need to remove the blank spaces before them.
I've used
Expand|Select|Wrap|Line Numbers
  1. array_walk($context_array, 'trim_value');
To trim the spaces using the function:
Expand|Select|Wrap|Line Numbers
  1.   function trim_value(&$value)
  2.   {
  3.     $value = trim($value, "\xC2\xA0");
  4.   }
This seems to have no effect. I need to convert my values into an array of single characters. I don't have PHP 5 so I've used a function to do the same job as str_split.

Expand|Select|Wrap|Line Numbers
  1.   //This fuction is almost the same as the fuction str_split included in php5.
  2.   function strsplt($thetext,$num)
  3.   {
  4.     if (!$num)
  5.     {
  6.       $num=1;
  7.     }
  8.     $arr=array();
  9.     $xfive=floor(strlen($thetext)/$num);
  10.     while ($ifive<=$xfive)
  11.     {
  12.       $yfive=substr($thetext,$jfive,$num);
  13.       if ($yfive)
  14.       {
  15.         array_push($arr,$yfive);
  16.       }
  17.       $ifive++;
  18.       $jfive=$jfive+$num;
  19.     }
  20.     return $arr;
  21.   }
However when I get the result for the blank space are not removed and for sections where I've used   it has changed it to  which means I get wired looking symbols. Can anyone suggest what it happening?
Mar 5 '10 #1
1 1738
KeredDrahcir
426 256MB
I'd like to know why this happened. I've fixed it chanigng the trim function to this:
function trim_value(&$value)
{
$value = trim($value, " , ");
}

I'd like to fix it proerly though.
Mar 5 '10 #2

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

Similar topics

9
by: Jean-Marc Molina | last post by:
Hello, I can't find a way to execute a Windows application, whose directory path contains blank spaces, from a PHP script. I also wonder if the problem happens under Linux and other OS. ...
6
by: Ruben | last post by:
Hello. I am trying to read a small text file using the readline statement. I can only read the first 2 records from the file. It stops at the blank lines or at lines with only spaces. I have a...
5
by: mark | last post by:
how to print, say 50 blank spaces, or say 20 blank spaces ? I wanted use such blank spaces that can be output in a program at predetermined places when printing with "cout".
1
by: Danny | last post by:
Given this: "*" the pattern to remove the htnl code between brackets, how can I remove a series of spaces and just make one space. like here is a series of blank...
2
by: Nimmy | last post by:
Hi, How can I print blank spaces with printf() I want something like printf("%6d %2d", lcVar1, lcVarb); Printout should be: 123123 34 12 spaces in between 123123 and 34 and 15...
1
by: Laser Lu | last post by:
Hi, all, I'm now writing a program to compress JavaScript code. One puzzle is how to write a regular expression to find out and remove all the redundent blank spaces. However, those blank spaces...
1
by: BethanyBez | last post by:
Is there any way when doing a merge with an Access Query and a columned Word doc that I can avoid blank spaces where the field is blank? I am creating a columned contact sheet with the contacts...
3
by: ShaeMills via AccessMonster.com | last post by:
In my table I imported from .txt, one of my columns has blank spaces. The column is as follows, how do I eliminate the blank spaces in between the second and third, and fifth and sixth digits? ...
1
by: abhilash12 | last post by:
validating blank spaces. The input box should accept the value - for eg "JOHN SMITH" but it should not allow two blank spaces.
1
by: maryanncanor | last post by:
Hi everyone, My problem is whenever I export a report to a textfile. The output textfile have blank spaces. Here is my query: SELECT ( & '|' & & '|'...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.