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
https://forums.phpfreaks.com/topic/257547-hellllllppppp-please/
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 )

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.