Jump to content

HELLLLLLPPPPP! PLease!!!


total noob

Recommended Posts

Hello to all

 

I need help on parsing this string

<?php "1" "+447980123456","+447980123456","","2009-06-03","13:15:17","hello world","Orange","843822651" "+447980123456","+447980123456","","2009-06-03","15:17:13","helloworld","Orange","843822652" "+447980123456","+447980123456","","2009-06-03","17:13:15","hello,world","Orange","843822653"  ?>

 

I've tried to use this code but it give's me a blank result.. I want to echo each element using foreach loop but it does not give me any result. can someone help me on this?

 

this is the code

 

<?php 
$file = '"1" "+447980123456","+447980123456","","2009-06-03","13:15:17","hello world","Orange","843822651" "+447980123456","+447980123456","","2009-06-03","15:17:13","helloworld","Orange","843822652" "+447980123456","+447980123456","","2009-06-03","17:13:15","hello,world","Orange","843822653"  ';
$toinks = 0;
$array = explode(',',$file );
foreach($array as $key => $value) {
$value = preg_replace('/#1#/','',$value);
$value =  preg_replace('/[^+0-9]/','',$value);
if ($value != '' || $value != NULL) {
	if (preg_match('/^\+/',$value)) {
		$newarray[$toinks] = $value;
		$toinks++;
	}
}
}

$wenkz = $newarray;

print_r($wenkz);
?>

 

ive tried using

<?php
foreach($file as $me){
echo $me;
}

or

foreach($file as $me=> $pols){
echo $pols[1];
}
?>

 

still it does not show me any result. Im nearing my deadline to finish my system. But im stuck on this.. Please help me!

 

thanks in advance :)

 

Link to comment
Share on other sites

my results using the exact code that you have provided:

 

$file = '"1" "+447980123456","+447980123456","","2009-06-03","13:15:17","hello world","Orange","843822651" "+447980123456","+447980123456","","2009-06-03","15:17:13","helloworld","Orange","843822652" "+447980123456","+447980123456","","2009-06-03","17:13:15","hello,world","Orange","843822653"  ';
$toinks = 0;
$array = explode(',',$file );
foreach($array as $key => $value) {
$value = preg_replace('/#1#/','',$value);
$value =  preg_replace('/[^+0-9]/','',$value);
if ($value != '' || $value != NULL) {
	if (preg_match('/^\+/',$value)) {
		$newarray[$toinks] = $value;
		$toinks++;
	}
}
}

$wenkz = $newarray;

print_r($wenkz);

 

results:

 

Array ( [0] => +447980123456 [1] => +447980123456 [2] => +447980123456 )

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.