Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Supporting Technologies > Server-Side Scripting

Reply
 
Thread Tools Rate Thread Display Modes
Old 01-13-2006, 04:04 AM   #1
fugitive123
an ardent learner
 
Join Date: Jan 2006
Posts: 114
Exclamation [Q] PHP->How to implode/explode without delimiter?

Can anybody tells me whether there is a built-in function to perform splitting or joining of arrays without using delimiter? Please don't give me alternative solution by ways of custom function. I know how to do it with my own function but I would like to know if there is already a PHP built-in function to cater for this scenario. TQ.
fugitive123 is offline   Reply With Quote
Old 01-13-2006, 04:06 AM   #2
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
Default

strstr
preg_match
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman
Flash Gordon is offline   Reply With Quote
Old 01-13-2006, 04:43 AM   #3
fugitive123
an ardent learner
 
Join Date: Jan 2006
Posts: 114
Default

Thanks. Will try to understand what these built-in functions you recommended will do. Actually I want to use simple solution to convert from string to array and array to string without having to manually split or join them. Built-in functions like explode and implode require only two lines of coding.
fugitive123 is offline   Reply With Quote
Old 01-13-2006, 04:52 AM   #4
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
Default

ActionScript Code:
Q = ("foobar").split(""); trace(Q);
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman

Last edited by Flash Gordon; 01-13-2006 at 05:10 AM..
Flash Gordon is offline   Reply With Quote
Old 01-13-2006, 05:40 AM   #5
fugitive123
an ardent learner
 
Join Date: Jan 2006
Posts: 114
Default

But the "split" example you gave above and "join" function are in ActionScript which accepts null delimiter. It's a different case in PHP which does not allow null delimiter and I end up writing my own function.
fugitive123 is offline   Reply With Quote
Old 01-13-2006, 05:46 AM   #6
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
Default

Perhaps if you knew why you are so attiment on not having a delimeter of create custom functions, we could help better.

Otherwise, just use the delimeter. It can't be that much of a hassle.
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman
Flash Gordon is offline   Reply With Quote
Old 01-13-2006, 06:17 AM   #7
fugitive123
an ardent learner
 
Join Date: Jan 2006
Posts: 114
Default

Actually, I'm trying to break up a long sentence and store each character into an array and perform some checking and manipulation, and then join them back again into a manipulated sentence without having to write a custom function to perform the conversion prior to and after the checking. I need to have a ready array with the each character of the Text being splitted into respective slot. before performing the necessary check. Without delimiter, I can't use the one line of "explode" and "implode" function . By using another custom function, the performance speed may be affected if the text is too big. Hope this helps to explain my concern.

I've been always trying to improve performance speed and reduce bandwidth cost and find any possible solution if applicable, use the already built-in function, otherwise, write my own custom function. BTW, thanks for providing the two built-in functions. Will look into them.
fugitive123 is offline   Reply With Quote
Old 01-13-2006, 07:06 AM   #8
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
Default

What you want can't be done. Here is a simple enough function to manipulate:

PHP Code:
<?php

function myFunc($str) {
    global 
$myArray;
    
$i 0;
    
    while(
strlen($str) > $i) {
        
$myArray[] = substr($str$i1);
        echo 
$myArray[$i] . "<br>";
        
$i++;
    }
    
}
$ok "Hello World";
myFunc($ok);

?>
Output:
Code:
H
e
l
l
o

W
o
r
l
d
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman

Last edited by Flash Gordon; 01-13-2006 at 07:15 AM..
Flash Gordon is offline   Reply With Quote
Old 01-13-2006, 07:45 AM   #9
fugitive123
an ardent learner
 
Join Date: Jan 2006
Posts: 114
Default

Thanks Flash. As I mentioned, I'm not asking for anybody to provide me a custom function. I myself had written my own custom function using a for loop, which used the strlen and substr like what you did above. Still, my main concern is the performance speed.....
fugitive123 is offline   Reply With Quote
Old 01-13-2006, 08:48 AM   #10
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
Default

there will be no performance hit with that code, I'm quite sure. Built-in functions do the same things.
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman
Flash Gordon is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
LoadVars or XML with PHP on DIFFERENT servers doesn't work. Sckz Server-Side Scripting 4 07-14-2005 12:01 AM
Problems loading PHP file into Flash lrempel ActionScript 2.0 1 01-25-2005 12:11 PM
Test-Movie using PHP doesn't work anymore on 10.3 Panther Sckz Server-Side Scripting 2 12-16-2004 03:00 AM
how to link Action Script to a remote PHP atomskreymx Server-Side Scripting 2 11-16-2004 07:01 AM


All times are GMT. The time now is 09:06 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.