Dividing a String into parts [SOLVED]
Moderator: General Moderators
- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
Dividing a String into parts [SOLVED]
I am having trouble remembering how to do this:
I have PHP printing this on a page:
1 - 2 - 3 - 4 - 5
I want another PHP page to "run" that page and get the HTML it outputs along with the numbers and then divide it by the " - " and delete the " - " all together. But I want it to do this for however long the string it so if its
1 - 2 - 3 - 4 - 5 - 6 - 7 it would do it 7 times and then put it in an array and then count the array and then print some stuff on that new page.
How would I do something like that?
Thanks,
Chris
I have PHP printing this on a page:
1 - 2 - 3 - 4 - 5
I want another PHP page to "run" that page and get the HTML it outputs along with the numbers and then divide it by the " - " and delete the " - " all together. But I want it to do this for however long the string it so if its
1 - 2 - 3 - 4 - 5 - 6 - 7 it would do it 7 times and then put it in an array and then count the array and then print some stuff on that new page.
How would I do something like that?
Thanks,
Chris
Last edited by tecktalkcm0391 on Wed Jul 26, 2006 4:12 pm, edited 6 times in total.
Code: Select all
implode();
explode();- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
Code: Select all
<?php
$str = include("../game/Florida/fantasy5.php");
// (up) outputs 3 - 17 - 22 - 26 - 32 or what ever numbers they change every so often
$numbers = array();
$numbers = explode(' - ', $str, -1);
print_r($numbers);
?>I was hoping your code would give me a better idea of what your trying to do, but here goes..
and then in page.php
Code: Select all
$numbers = explode(' - ', $str, -1);
$numbers = implode('.', $numbers);
echo '<a href="page.php?values="' . $numbers . '">ARG</a>';Code: Select all
$numbers = explode('.', $_GET['values']);- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
OK, well here is a better idea of what I am trying to do.. I have a script that is outputting numbers.... the a format of X - X - X - X - X and I want to extract each of the numbers by somehow getting the numbers from the page that generates them (numbers.php, which users never see or go to) putting them into a string on (page.php, which is what the users see) and then printing them for a parameter for a flash animation in the following.
Code: Select all
<param name="flashvars" value="num1=(NUMBER 1)&num2=(NUMBER 2)&num3=(NUMBER 3)&num4=(NUMBER 4)&num5=(NUMBER 5)">untested..
astions is closed till tomorrow.. gotta get some sleep 
Code: Select all
$numbers = explode('.', $_GET['values'])
$counter = 1;
$queryString = '?';
foreach ($numbers as $value)
{
$queryString .= 'num' . $counter . '=' . $value . '&';
$counter++;
}
$queryString = substr($queryString, 0, -1);
$paramString = '<param name="flashvars" value="' . $queryString . '">';- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
a logical file_get_contents()... come on now, you aren't doing research anymore?
- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
Sorry. I've been doing the research I even found that, but I keep getting stuff that is wrong. At one time I was getting the PHP codes from the page in the source code.feyd wrote:a logical file_get_contents()... come on now, you aren't doing research anymore?
- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
How would I do that anyways, if I do it like this:
I get the PHP Codes in the source, and nothing on the page.
If I do
I get
Code: Select all
$sFile = file_get_contents("home/dir/numbers.php");
if($sFile==FALSE){
print 'error';
}
print $sFile;If I do
Code: Select all
$sFile = file_get_contents("http://site.com/dir/numbers.php");
if($sFile==FALSE){
print 'error';
}
print $sFile;Warning: file_get_contents(http://site.com/dir/numbers.phphp) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 401 Authorization Required in /home/test.php on line 3
error
- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida