Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Built In Function To Right Chop A String?


Is there one built into PHP?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Chop The String After 100 Char Count?
i have a string.. e.g "this is a test string to test whether the string char exceed
100 char?" how do i display only the first n char (include spaces) e.g. 21 char will be
"this is a test string".

Word Function Pre Built
I was reading that post about shout box and that swear word blocker I was wondering if someone have an array pre built (well built) of words I can reference off of.

Chop() Not Working?
I have a string in $values, with some comma separated values, such as:

$values = "value1, value2, value3";

With this function i want to create an array containing this values:

function createArray($string) {
// remove spaces
$string = chop ($string);
// explode string into array
$valuesArray = explode (",", $string);
return $valuesArray;
}
$myArray = createArray($values);

the problem is that chop() does not remove spaces and i get an array of values containg white spaces.

Am i using the wrong function? Or what?

(PHP version on my server is 3.0.16)

Chop Sting
When i access the date Column in Mysql i get the following result "2007-06-16 14:02:49" What string function do i use to chop off the time.

Parse Part Of String (mid String Function ?)
Can someone tell me how to parse part of a string? I can use the following:

<?php
$text = $_SERVER['PHP_SELF']; //$PHP_SELF //(document.url);
echo $text;
?>

to get this result:

"Your currently at /test.php "

I just want to get "test.php " without the dash. I also need to parse out
parts of other strings. I know how to use Mid(), Left(), and Right() in VB,
but no clue for PHP.

How To Chop And Rearrange A Name Field?
i've got a field in a mySQL db for "name". the program that exports the data for my db does that export as "Doe, John"... just like that. backwards a sep'ed by a comma. when i pull it into my PHP page i'd like to display it as "John Doe". how do i pull this off?

Chop Down To Given Amount Of Chars
I need to take a string and reduce it to a given amount of characters, chop and trim seem to take a substring to chop at but i need it to be a set number or characters can anyone help?

Is There A Function To Search A String Within Another String ?
for e.g, fnding the word "hello" in this string : "hello world"...

Php W/ Built In Mysql
I've downloaded an apache binary for my windows platform. I installed a php 4 binary, and read that it has built-in MySQL support. But I also read that you need to specify the root for mysql databases in the compiltation process. But I didn't need to compile anything, because I had a binary distro. What do I need to do. Download a binary from MySQL?

Web Built Using PHP Scripting
I was asked to take over a web application that written using PHP
scripting. The applicaiton is used for monitoring server & network
availability and perforamnce. There is no documentation for this
application and I'm new to PHP.

What should I ask from the hand over person before he leave?

PHP-built META Tag Not Working. Help :)
I need to buid the redirect to another page with some parameters. For some weird reason (or my mistake) it doesn´t redirect me anywere and prints on-screen this:

-23">

If I do a simple echo of a meta-tag it DOES work, so I guess I have a problem with the creation of the string.

I am pretty burnt out, here´s the code:

Built-in Oracle Support
I was just confused whether PHP has built in support for Oracle. If my database server is a windows 2000 server with oracle 8 installed, How can i access it from a different webserver running solaris and apache. How I will have to configure PHP on solaris to connect to database on win2000.

Advice On Forum To Built
I'm going to build a simple forum in mySQL.
I've thought about it for a while now, but still can't figure it
out completely:

If i have say 5 main categories,
One has 5 sub-categories.
Each sub category consists of individual threads.
Wich each has the possibility to be commented.

The question concerns the thread & comments part.
My first idea was to create one table Threads, and one
Comments.
The Threads-table would have the original post, starting a thread,
and the Comments table would have the comment, and the id of
the thread it belongs to. (so all comments there are in the whole
forum)

Now i thought of the following:
I could create a new table for each thread to save it's comments in.
And call it e.g. 'Comments_4576', (belonging to thread 4576)

Pro is a lot faster to load, delete etc. but contra is more difficult
to
count cross-tables and everything.

Where Is A Website Built Of Sub-websites?
I'm not sure what to call what I want, but I will describe my intent,
hoping that someone will offer a resource for a ready-built solution.

I sell construction products to a group of about 50 subcontractors.
Some of them have their own websites, but many do not. I want to
offer my clients a central site that can host sub-sites, one for each
client. All will be under my domain:
my-domain.com/customer1
my-domain.com/customer2
etc.

This will be a free service I am offering them - sort of a promotional
tool, like a digital coffee cup. Therefore, I need to minimize my own
involvement in maintaining the site. I want each client to be able to
individually administer his/her own site. They should be able to
create webpages (perhaps reporting on their general capabilities or on
major projects they have completed) from a set of pre-designed
templates. I want them to only have to enter text and upload images.
There should be a separate admin function for each client, with
username and password facilities.

I could program such a system, I suppose, using a templating system
like Smarty. Perhaps I could find plugins that would provide the
admin functions. However, I was hoping that this rather elementary
problem had already been solved and someone could point me in the
right direction.

Cyrus_authenticate() Built Into Php4?
I would like to use built-in functions in php to execute some cyrus-imap
operation. Does PHP support these operation?

Anyone Built A Statically Linked PHP?
We'd like to build a version of the command line
PHP (i.e. don't plan on running/building the apache module) and
have it statically linked to minimize other system
dependencies.

Has anyone actually done this? Don't see much on the
web, a few folks offered changing configure to add
LDFLAGS=-all-static , but that doesn't seem to do it?

Built-in Syntax Highlighting In Php 4.1
nl2br() started outputting <br /> as of 4.05 - however, my memory tells me that the functions highlight_string() and highlight_file() didn't get around to switching from <br> to <br /> until later. Anyone remember if 4.1's syntax highlighting had <br> or <br />'s in it, or have their own 4.1.x install to test? If it's <br> I'll have to account for this in my script.

String Function
I'd like to know whether there's a php function that transform a string into
html... espacially turning
to <br> etc.
I couldn't find it in the php doc.

String Contains Function
Is there a function in PHP that will return a boolean if a String
contains another given String. As what I am trying to do is disallow
input that contains ../ or something else that would allow directory
traversal.

Disabling The Built-in POST Handler
I need to handle very large file uploads and push the data into a socket.
Having php to write everything to a temporary file, then reading it
again inside the script and pushing it into the socket is very inefficient
and imposes size limitations to the uploaded files (which may reach GB
in size)....

Why No Type Hints For Built-in Types?
I'm new here, and sorry if this has been discussed before; I didn't find it
searching the PHP groups. (I've also read recommendations to cross-post to
the other PHP groups, but if that is discouraged, please let me know. At the
same time, please then let me know which of the many PHP groups to post to.

In PHP5, you can provide "type hints" for functions, like this:

IE Users Not Being Able To Login To PHP Built Site
A few weeks ago, some of our members started reported not being able to login with IE. I have XP and get automatic updates.

I used to be able to login using IE. I found that I now can not login using IE, but can login to members section using Netscape. The site is built in PHP and the site files have not changed.

Anyone else experiencing this type of problem with IE? I've already tried accepting ALL cookies, activex settings are on, dumping cookies, temp files, security setting is LOW.

Downloading A Dynamically Built File
i'm trying to build a comma-separated file for my users to download summaries of information in the database. i did it once before and it worked fine, but this time it's in the context of a frameset and there are some problems. i have a form that calls the test script below, and the form's target is a hidden frame in my frameset. Code:

[ZEND API] Accessing Built In Functions
how can I access built in PHP fuction (such as array_* functions) when
developing a C extension??
Does the names of the functions change or it remains the same alse in C
source code??

Any good tutorial on the net about writing PHP extensions?

Someone read "Writing custom PHp Extensions"?

Making Php Module Built Into Apache ?
I would like to build php within apache itself so that it makes my
sysadmin life easy. Is there a way to acomplish that ? I would like to
do it for windows and for linux.

Multi String Function
I am trying to create my own template engine.. nothing serious just for personal use but I want to make a certain function that I do now know how to make.. basicly it should work like this template($templatename, $var1, $var2, $var3);

though the $var's will be different each time, so with one template it'll only be one var and with another 5.. and I have no idea how to get that done. I want the function to get the template from the database and convert [var1] to $var1 etc.

String 'starts With' Function
I have looked at the PHP string functions and I cant see any function to
check to see whether a string starts with a certain letter or letters. Is
there any way of doing this with the built in functions?

Returning A String From A Function
if (isset($search)){
return "<A HREF=javascript:popUp(emailsearch.php?mysearch=".$search.")>Email Search to Friend[/url]";}

something wrong in my return statement. The popup window is not opening.     

Translate String To Function Arguments
I have this:

<headline size="2" color="#000000">Hello World!</headline>

I have already done all the coding to pass this to a PHP function this way:

function headline($content){
print "<span class='headline'>$content</span>";
}

So the <headline...> example would result in:

<span class='headline'> Hello World!</span>

So far so great. But you might have noticed the arguments in the original
string? I want to pass those! I would prefer to have them this way:

headline("Hello World", "color=#000000", "size=2");

And then extrat them with func_get_arg(). But how do I translate a string to
seperated arguments for a function?

Correct XML String Creation Function
Is there a php function that can translate any string to it's correct XML equivalent? Like for instance when I have the following script: PHP Code:

String Function In PHP To Make The Searching Of Tags
I not sure if bbcode was the term for this.. how this can be done? for example in this forum, with the open and closing some code here or [/img]link of image here[/img] and on the display it is display with a ceratin CSS/format or something..is this can be done through "eregular expression"? and before saving on the dbase is converted to <img src"" />? am I right? 

is there a string function in PHP to make the searching of tags easy?

Function Will Check To See If One String Exists In Anther
I am looking for a function that will check to see if one string exists in anther. here is an example.

$stringa = "new";
$stringb = "Show new replies to you posts"

if ($stringa is in $stringb){
   do something here
}

any ideas?

Function To Find 6 Digit Numeric String
I need to parse a string and attempt to find a substring in the string that contains 6 numeric digits. the first and last digit may or may not be preceded by a space.

I need to find the starting the ending positions of the 6 numeric digits to that I can extract the string and build an href containing the string and replace those 6 digits with a hyperlink.

Function To Search A String For Tags Using A Css Selector
Does any one know of a function that can be used to search a string for html tags using a css selector.

Make Function Equal To String In Conditional
I can usually figure something out, but I CANNOT figure this one out: This is a classified word ad script to count the words in a text area ($wrdad) and multiply it by the rate for how many times the ad will run in the newspaper.  I know my code is messy and ameture, don't be too critical, but it works - everythign except one part. We have a 15 word minimum. I have this area commented out as //Problem Area/// in the code below.

In a nutshell, I want function wordcount($wordad) to be equal to 15 if there are fewer than 15 words in the $wordad textarea. It just seems to ignore the wordcount($wordad) == 15; in my conditional. Code:

Handling Multiple PortType Definitions With The Same Method Name With Built-in SOAP
I am trying to communicate with a WSDL that defines to portTypes:

- <portType name="General">
- <portType name="Session">

And their exists 2 operations with the same name but in 2 different
porttypes (the general "GetList" returns a default list of items, the
session "GetList" requires a session ID to be passed in the header and
returns a list based on the session ID):

- <operation name="GetList">
<soap:operation soapAction="urn:XXX-General#GetList" style="rpc" />
- <input message="tns:GetListRequest">
<soap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:XXX-General" />
</input>

- <operation name="GetList">
<soap:operation soapAction="urn:XXX-Session#GetList" style="rpc" />
- <input message="tns:GetListRequest">
<soap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:XXX-Session" />
</input>

When I try to create a client using the build-in SOAP (PHP 5.1 beta 3),
like this:

$client = new SoapClient('http://localhost:8095/soap',
array("trace"=>1, "exceptions"=>0));

I get the message:

Fatal error: SOAP-ERROR: Parsing WSDL: 'GetListRequest' already defined
in d:InetpubPHPsoaptest.php on line 12

Is there a way to handle this situation so that I can specify the
portType, service name, or port name so that the available methods
won't be duplicates?

Apache / PHP Page Built From A MySQL Database Diplay Problems
Here is the basic scenario:

- Configuration data is gathered from Oracle servers then ftp'd to my
apache / mysql server.

- The apache / mysql server receives the datafile from the Oracle
clients and loads the data into a MySQL database.

- The webpages are coded using PHP, SQL, and some JavaScript.

Now here is where it gets weird....

- When the data is displayed (pages are based upon the configuration
of each Oracle <server-name>+<database-instance-name>, some times the
data displays other times the page is simply blank? It is only for a
few out of the many that we have in the MySQL database. It is always
the same ones with the problem. Re-loading the data for those problem
<server-name>+<database-instance-name> does not fix it.

Anyone see this before? Could it be a special character that the web
browser cannot handle? I am at a loss on this one.

Function To Check For Multiple Instances Of A String In An Array?
I need to check if there are more than one of the same string in an array. Does anyone know of a function?

How To Stamp "chop / Timestamp" On A Jpg In Php?
how to stamp "chop / timestamp" on a jpg in php?

Make Text String Read From Right To Left In Imagettftext() Function
I want to write a text string from right to left instead of from left to right with the imagettftext (); function

I read in teh manual that the angle variable controls this, it says that 0 angle means left to right, so I tried 180, 360 but nothing happens

What angle do I need to put it to get it to write it right to left

I am writing a hebrew text string with a font.ttf that supports hebrew characters

<?php   
$white = imagecolorallocate($background, 255, 255, 255);
$fontfile = "davidtr.ttf";
$string = "&#1502;&#1495;&#1500;&#1491;&#1490;&#1499;";
imagettftext($background, 12, 360, 3, 17, $white, $fontfile, $string);
?>

Attaching A String To A Normal Word Without Loosing The String
In my database I have content rows that are either called <contentname>_title or <contentname>_fulltext. now when someone clicks a link on the site it goes to index.php?action=<contentname> so I guess you see where im going..

when someone goes to such a section index.php sees $action is used and attaches it to _title and _fulltext, so u get: $action_fulltext.. basicly of cuz php now sees it as one string '$action_fulltext' and not '$action'_fulltext.

String -> String That Is Compatible With Linux File System.
Does a function excist that converts a string to a string thats compatible
with linux file system?



Insert String Into String Based On Number Of Chars
Say I had

$string = "I swear I have seen this before.";

I want to add

$addme = "**";

into the original string after 10 characters.  How would I do this?

Help - Regexp For Extracting A String From A Larger String
I am developing a very basic CMS for a website I'm working on. One of the requirements is for the client to be able to post an image in their news posts, as well as links. I've got the links working (sort of, because I fear the way I have set it up may break images).

Ideally I would like something like BBcode but can't wrap my head around regular expressions.

Search A String And Return String Between Char?
I have a string like this;

Full Name (Department)

How can I split that string into seperate strings for Full Name and Department, so that everything before the () is the full name and everything between the () is the department?

Partially Replace A String With Data From The Same String...
I'm trying to write a script to help import some old HTML files as blog post for my website, these HTML files are 300-2000 lines long. I am currently using fgets() to read the files one line at a time, clean them and write them to the database in the appropriate format once the entire article is completed.

My issue is many of the links included on these post no longer exist (some date into the '90s) and I want as part of my importing function to "fix" these links as so. Code:

Searching For A Recurring String In A String
I am teaching myself PHP. I have an HTML page with various products
each with a specific reference in the form "Reference XXX". I would
like to put an email link below each product with the product reference
as part of the subject of the email link.

What kind of procedure would you use? Could you please put me in the...

String To Filename-friendly-string
I've got a database whith titles of pages and I want to use them in my filenames (with Modrewrite). But, I have to use a function to convert them to filename-friendly-strings.

e.g.
title:"What's thàt!?" should become something like:
whats-that(.html)

title:YOU & M€ should become you-m.html [ignoring strange characters]

Someone who has got that function?

Converting A Hex String To A Binary String?
I have a situation where I have an 8-byte string which is represented as 16 hex digits. How do I convert a 16 hex digit string to an 8-byte binary string?

I know I can use bin2hex to go from a binary string to a hex string (very useful)but is there a way to go the other direction? Right now I have a solution, which is to use a loop to go through the hex string one byte at a time, but that doesn't seem like a good way to do it. It seems like I should be able to use the pack() command, but I can't get it to work.


Copyright © 2005-08 www.BigResource.com, All rights reserved